Merge "Add support for AudioAttributes in android.media.Ringtone" into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 8b2f69a..5c2a9d5 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -272,14 +272,14 @@
     field public static final int action = 16842797; // 0x101002d
     field public static final int actionBarDivider = 16843675; // 0x101039b
     field public static final int actionBarItemBackground = 16843676; // 0x101039c
-    field public static final int actionBarPopupTheme = 16843917; // 0x101048d
+    field public static final int actionBarPopupTheme = 16843919; // 0x101048f
     field public static final int actionBarSize = 16843499; // 0x10102eb
     field public static final int actionBarSplitStyle = 16843656; // 0x1010388
     field public static final int actionBarStyle = 16843470; // 0x10102ce
     field public static final int actionBarTabBarStyle = 16843508; // 0x10102f4
     field public static final int actionBarTabStyle = 16843507; // 0x10102f3
     field public static final int actionBarTabTextStyle = 16843509; // 0x10102f5
-    field public static final int actionBarTheme = 16843825; // 0x1010431
+    field public static final int actionBarTheme = 16843827; // 0x1010433
     field public static final int actionBarWidgetTheme = 16843671; // 0x1010397
     field public static final int actionButtonStyle = 16843480; // 0x10102d8
     field public static final int actionDropDownStyle = 16843479; // 0x10102d7
@@ -291,15 +291,15 @@
     field public static final int actionModeCloseDrawable = 16843484; // 0x10102dc
     field public static final int actionModeCopyDrawable = 16843538; // 0x1010312
     field public static final int actionModeCutDrawable = 16843537; // 0x1010311
-    field public static final int actionModeFindDrawable = 16843898; // 0x101047a
+    field public static final int actionModeFindDrawable = 16843900; // 0x101047c
     field public static final int actionModePasteDrawable = 16843539; // 0x1010313
     field public static final int actionModeSelectAllDrawable = 16843646; // 0x101037e
-    field public static final int actionModeShareDrawable = 16843897; // 0x1010479
+    field public static final int actionModeShareDrawable = 16843899; // 0x101047b
     field public static final int actionModeSplitBackground = 16843677; // 0x101039d
     field public static final int actionModeStyle = 16843668; // 0x1010394
-    field public static final int actionModeWebSearchDrawable = 16843899; // 0x101047b
+    field public static final int actionModeWebSearchDrawable = 16843901; // 0x101047d
     field public static final int actionOverflowButtonStyle = 16843510; // 0x10102f6
-    field public static final int actionOverflowMenuStyle = 16843844; // 0x1010444
+    field public static final int actionOverflowMenuStyle = 16843846; // 0x1010446
     field public static final int actionProviderClass = 16843657; // 0x1010389
     field public static final int actionViewClass = 16843516; // 0x10102fc
     field public static final int activatedBackgroundIndicator = 16843517; // 0x10102fd
@@ -326,8 +326,8 @@
     field public static final int alphabeticShortcut = 16843235; // 0x10101e3
     field public static final int alwaysDrawnWithCache = 16842991; // 0x10100ef
     field public static final int alwaysRetainTaskState = 16843267; // 0x1010203
-    field public static final int amPmBackgroundColor = 16843942; // 0x10104a6
-    field public static final int amPmTextColor = 16843941; // 0x10104a5
+    field public static final int amPmBackgroundColor = 16843944; // 0x10104a8
+    field public static final int amPmTextColor = 16843943; // 0x10104a7
     field public static final int angle = 16843168; // 0x10101a0
     field public static final int animateFirstView = 16843477; // 0x10102d5
     field public static final int animateLayoutChanges = 16843506; // 0x10102f2
@@ -347,7 +347,7 @@
     field public static final int autoCompleteTextViewStyle = 16842859; // 0x101006b
     field public static final int autoLink = 16842928; // 0x10100b0
     field public static final int autoMirrored = 16843754; // 0x10103ea
-    field public static final int autoRemoveFromRecents = 16843847; // 0x1010447
+    field public static final int autoRemoveFromRecents = 16843849; // 0x1010449
     field public static final int autoStart = 16843445; // 0x10102b5
     field public static final deprecated int autoText = 16843114; // 0x101016a
     field public static final int autoUrlDetect = 16843404; // 0x101028c
@@ -356,8 +356,8 @@
     field public static final int backgroundDimEnabled = 16843295; // 0x101021f
     field public static final int backgroundSplit = 16843659; // 0x101038b
     field public static final int backgroundStacked = 16843658; // 0x101038a
-    field public static final int backgroundTint = 16843883; // 0x101046b
-    field public static final int backgroundTintMode = 16843884; // 0x101046c
+    field public static final int backgroundTint = 16843885; // 0x101046d
+    field public static final int backgroundTintMode = 16843886; // 0x101046e
     field public static final int backupAgent = 16843391; // 0x101027f
     field public static final int banner = 16843762; // 0x10103f2
     field public static final int baseline = 16843548; // 0x101031c
@@ -377,18 +377,18 @@
     field public static final int bufferType = 16843086; // 0x101014e
     field public static final int button = 16843015; // 0x1010107
     field public static final int buttonBarButtonStyle = 16843567; // 0x101032f
-    field public static final int buttonBarNegativeButtonStyle = 16843915; // 0x101048b
-    field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
-    field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
+    field public static final int buttonBarNegativeButtonStyle = 16843917; // 0x101048d
+    field public static final int buttonBarNeutralButtonStyle = 16843916; // 0x101048c
+    field public static final int buttonBarPositiveButtonStyle = 16843915; // 0x101048b
     field public static final int buttonBarStyle = 16843566; // 0x101032e
     field public static final int buttonStyle = 16842824; // 0x1010048
     field public static final int buttonStyleInset = 16842826; // 0x101004a
     field public static final int buttonStyleSmall = 16842825; // 0x1010049
     field public static final int buttonStyleToggle = 16842827; // 0x101004b
-    field public static final int buttonTint = 16843887; // 0x101046f
-    field public static final int buttonTintMode = 16843888; // 0x1010470
+    field public static final int buttonTint = 16843889; // 0x1010471
+    field public static final int buttonTintMode = 16843890; // 0x1010472
     field public static final int cacheColorHint = 16843009; // 0x1010101
-    field public static final int calendarTextColor = 16843931; // 0x101049b
+    field public static final int calendarTextColor = 16843933; // 0x101049d
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
     field public static final int canRequestEnhancedWebAccessibility = 16843736; // 0x10103d8
@@ -406,8 +406,8 @@
     field public static final int centerY = 16843171; // 0x10101a3
     field public static final int checkBoxPreferenceStyle = 16842895; // 0x101008f
     field public static final int checkMark = 16843016; // 0x1010108
-    field public static final int checkMarkTint = 16843944; // 0x10104a8
-    field public static final int checkMarkTintMode = 16843945; // 0x10104a9
+    field public static final int checkMarkTint = 16843946; // 0x10104aa
+    field public static final int checkMarkTintMode = 16843947; // 0x10104ab
     field public static final int checkable = 16843237; // 0x10101e5
     field public static final int checkableBehavior = 16843232; // 0x10101e0
     field public static final int checkboxStyle = 16842860; // 0x101006c
@@ -426,31 +426,31 @@
     field public static final int clipChildren = 16842986; // 0x10100ea
     field public static final int clipOrientation = 16843274; // 0x101020a
     field public static final int clipToPadding = 16842987; // 0x10100eb
-    field public static final int closeIcon = 16843905; // 0x1010481
+    field public static final int closeIcon = 16843907; // 0x1010483
     field public static final int codes = 16843330; // 0x1010242
     field public static final int collapseColumns = 16843083; // 0x101014b
     field public static final int color = 16843173; // 0x10101a5
-    field public static final int colorAccent = 16843829; // 0x1010435
+    field public static final int colorAccent = 16843831; // 0x1010437
     field public static final int colorActivatedHighlight = 16843664; // 0x1010390
     field public static final int colorBackground = 16842801; // 0x1010031
     field public static final int colorBackgroundCacheHint = 16843435; // 0x10102ab
-    field public static final int colorButtonNormal = 16843819; // 0x101042b
-    field public static final int colorControlActivated = 16843818; // 0x101042a
-    field public static final int colorControlHighlight = 16843820; // 0x101042c
-    field public static final int colorControlNormal = 16843817; // 0x1010429
+    field public static final int colorButtonNormal = 16843821; // 0x101042d
+    field public static final int colorControlActivated = 16843820; // 0x101042c
+    field public static final int colorControlHighlight = 16843822; // 0x101042e
+    field public static final int colorControlNormal = 16843819; // 0x101042b
     field public static final int colorFocusedHighlight = 16843663; // 0x101038f
     field public static final int colorForeground = 16842800; // 0x1010030
     field public static final int colorForegroundInverse = 16843270; // 0x1010206
     field public static final int colorLongPressedHighlight = 16843662; // 0x101038e
     field public static final int colorMultiSelectHighlight = 16843665; // 0x1010391
     field public static final int colorPressedHighlight = 16843661; // 0x101038d
-    field public static final int colorPrimary = 16843827; // 0x1010433
-    field public static final int colorPrimaryDark = 16843828; // 0x1010434
+    field public static final int colorPrimary = 16843829; // 0x1010435
+    field public static final int colorPrimaryDark = 16843830; // 0x1010436
     field public static final int columnCount = 16843639; // 0x1010377
     field public static final int columnDelay = 16843215; // 0x10101cf
     field public static final int columnOrderPreserved = 16843640; // 0x1010378
     field public static final int columnWidth = 16843031; // 0x1010117
-    field public static final int commitIcon = 16843909; // 0x1010485
+    field public static final int commitIcon = 16843911; // 0x1010487
     field public static final int compatibleWidthLimitDp = 16843621; // 0x1010365
     field public static final int completionHint = 16843122; // 0x1010172
     field public static final int completionHintView = 16843123; // 0x1010173
@@ -461,11 +461,11 @@
     field public static final int content = 16843355; // 0x101025b
     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 contentInsetLeft = 16843861; // 0x1010455
-    field public static final int contentInsetRight = 16843862; // 0x1010456
-    field public static final int contentInsetStart = 16843859; // 0x1010453
-    field public static final int contentRatingSystemXml = 16843955; // 0x10104b3
+    field public static final int contentInsetEnd = 16843862; // 0x1010456
+    field public static final int contentInsetLeft = 16843863; // 0x1010457
+    field public static final int contentInsetRight = 16843864; // 0x1010458
+    field public static final int contentInsetStart = 16843861; // 0x1010455
+    field public static final int contentRatingSystemXml = 16843957; // 0x10104b5
     field public static final int controlX1 = 16843798; // 0x1010416
     field public static final int controlX2 = 16843800; // 0x1010418
     field public static final int controlY1 = 16843799; // 0x1010417
@@ -478,12 +478,12 @@
     field public static final int dashGap = 16843175; // 0x10101a7
     field public static final int dashWidth = 16843174; // 0x10101a6
     field public static final int data = 16842798; // 0x101002e
-    field public static final int datePickerDialogTheme = 16843949; // 0x10104ad
-    field public static final int datePickerMode = 16843956; // 0x10104b4
+    field public static final int datePickerDialogTheme = 16843951; // 0x10104af
+    field public static final int datePickerMode = 16843958; // 0x10104b6
     field public static final int datePickerStyle = 16843612; // 0x101035c
     field public static final int dateTextAppearance = 16843593; // 0x1010349
-    field public static final int dayOfWeekBackgroundColor = 16843924; // 0x1010494
-    field public static final int dayOfWeekTextAppearance = 16843925; // 0x1010495
+    field public static final int dayOfWeekBackgroundColor = 16843926; // 0x1010496
+    field public static final int dayOfWeekTextAppearance = 16843927; // 0x1010497
     field public static final int debuggable = 16842767; // 0x101000f
     field public static final int defaultValue = 16843245; // 0x10101ed
     field public static final int delay = 16843212; // 0x10101cc
@@ -514,7 +514,7 @@
     field public static final int dividerHorizontal = 16843564; // 0x101032c
     field public static final int dividerPadding = 16843562; // 0x101032a
     field public static final int dividerVertical = 16843530; // 0x101030a
-    field public static final int documentLaunchMode = 16843845; // 0x1010445
+    field public static final int documentLaunchMode = 16843847; // 0x1010447
     field public static final int drawSelectorOnTop = 16843004; // 0x10100fc
     field public static final int drawable = 16843161; // 0x1010199
     field public static final int drawableBottom = 16843118; // 0x101016e
@@ -543,8 +543,8 @@
     field public static final int editTextStyle = 16842862; // 0x101006e
     field public static final deprecated int editable = 16843115; // 0x101016b
     field public static final int editorExtras = 16843300; // 0x1010224
-    field public static final int elegantTextHeight = 16843869; // 0x101045d
-    field public static final int elevation = 16843840; // 0x1010440
+    field public static final int elegantTextHeight = 16843871; // 0x101045f
+    field public static final int elevation = 16843842; // 0x1010442
     field public static final int ellipsize = 16842923; // 0x10100ab
     field public static final int ems = 16843096; // 0x1010158
     field public static final int enabled = 16842766; // 0x101000e
@@ -554,10 +554,10 @@
     field public static final int entries = 16842930; // 0x10100b2
     field public static final int entryValues = 16843256; // 0x10101f8
     field public static final int eventsInterceptionEnabled = 16843389; // 0x101027d
-    field public static final int excludeClass = 16843842; // 0x1010442
+    field public static final int excludeClass = 16843844; // 0x1010444
     field public static final int excludeFromRecents = 16842775; // 0x1010017
-    field public static final int excludeId = 16843841; // 0x1010441
-    field public static final int excludeName = 16843854; // 0x101044e
+    field public static final int excludeId = 16843843; // 0x1010443
+    field public static final int excludeName = 16843856; // 0x1010450
     field public static final int exitFadeDuration = 16843533; // 0x101030d
     field public static final int expandableListPreferredChildIndicatorLeft = 16842834; // 0x1010052
     field public static final int expandableListPreferredChildIndicatorRight = 16842835; // 0x1010053
@@ -588,7 +588,7 @@
     field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339
     field public static final int fillAfter = 16843197; // 0x10101bd
     field public static final int fillBefore = 16843196; // 0x10101bc
-    field public static final int fillColor = 16843806; // 0x101041e
+    field public static final int fillColor = 16843807; // 0x101041f
     field public static final int fillEnabled = 16843343; // 0x101024f
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
@@ -602,12 +602,12 @@
     field public static final int focusableInTouchMode = 16842971; // 0x10100db
     field public static final int focusedMonthDateColor = 16843587; // 0x1010343
     field public static final int fontFamily = 16843692; // 0x10103ac
-    field public static final int fontFeatureSettings = 16843960; // 0x10104b8
+    field public static final int fontFeatureSettings = 16843962; // 0x10104ba
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
     field public static final int foreground = 16843017; // 0x1010109
     field public static final int foregroundGravity = 16843264; // 0x1010200
-    field public static final int foregroundTint = 16843885; // 0x101046d
-    field public static final int foregroundTintMode = 16843886; // 0x101046e
+    field public static final int foregroundTint = 16843887; // 0x101046f
+    field public static final int foregroundTintMode = 16843888; // 0x1010470
     field public static final int format = 16843013; // 0x1010105
     field public static final int format12Hour = 16843722; // 0x10103ca
     field public static final int format24Hour = 16843723; // 0x10103cb
@@ -621,13 +621,13 @@
     field public static final int freezesText = 16843116; // 0x101016c
     field public static final int fromAlpha = 16843210; // 0x10101ca
     field public static final int fromDegrees = 16843187; // 0x10101b3
-    field public static final int fromId = 16843850; // 0x101044a
+    field public static final int fromId = 16843852; // 0x101044c
     field public static final int fromScene = 16843741; // 0x10103dd
     field public static final int fromXDelta = 16843206; // 0x10101c6
     field public static final int fromXScale = 16843202; // 0x10101c2
     field public static final int fromYDelta = 16843208; // 0x10101c8
     field public static final int fromYScale = 16843204; // 0x10101c4
-    field public static final int fullBackupOnly = 16843891; // 0x1010473
+    field public static final int fullBackupOnly = 16843893; // 0x1010475
     field public static final int fullBright = 16842954; // 0x10100ca
     field public static final int fullDark = 16842950; // 0x10100c6
     field public static final int functionalTest = 16842787; // 0x1010023
@@ -640,7 +640,7 @@
     field public static final int gestureStrokeType = 16843385; // 0x1010279
     field public static final int gestureStrokeWidth = 16843380; // 0x1010274
     field public static final int glEsVersion = 16843393; // 0x1010281
-    field public static final int goIcon = 16843906; // 0x1010482
+    field public static final int goIcon = 16843908; // 0x1010484
     field public static final int gradientRadius = 16843172; // 0x10101a4
     field public static final int grantUriPermissions = 16842779; // 0x101001b
     field public static final int gravity = 16842927; // 0x10100af
@@ -653,16 +653,16 @@
     field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e
     field public static final int hardwareAccelerated = 16843475; // 0x10102d3
     field public static final int hasCode = 16842764; // 0x101000c
-    field public static final int headerAmPmTextAppearance = 16843936; // 0x10104a0
+    field public static final int headerAmPmTextAppearance = 16843938; // 0x10104a2
     field public static final int headerBackground = 16843055; // 0x101012f
-    field public static final int headerBackgroundColor = 16843937; // 0x10104a1
-    field public static final int headerDayOfMonthTextAppearance = 16843927; // 0x1010497
+    field public static final int headerBackgroundColor = 16843939; // 0x10104a3
+    field public static final int headerDayOfMonthTextAppearance = 16843929; // 0x1010499
     field public static final int headerDividersEnabled = 16843310; // 0x101022e
-    field public static final int headerMonthTextAppearance = 16843926; // 0x1010496
-    field public static final int headerTimeTextAppearance = 16843935; // 0x101049f
-    field public static final int headerYearTextAppearance = 16843928; // 0x1010498
+    field public static final int headerMonthTextAppearance = 16843928; // 0x1010498
+    field public static final int headerTimeTextAppearance = 16843937; // 0x10104a1
+    field public static final int headerYearTextAppearance = 16843930; // 0x101049a
     field public static final int height = 16843093; // 0x1010155
-    field public static final int hideOnContentScroll = 16843843; // 0x1010443
+    field public static final int hideOnContentScroll = 16843845; // 0x1010445
     field public static final int hint = 16843088; // 0x1010150
     field public static final int homeAsUpIndicator = 16843531; // 0x101030b
     field public static final int homeLayout = 16843549; // 0x101031d
@@ -698,8 +698,8 @@
     field public static final int indeterminateDuration = 16843069; // 0x101013d
     field public static final int indeterminateOnly = 16843066; // 0x101013a
     field public static final int indeterminateProgressStyle = 16843544; // 0x1010318
-    field public static final int indeterminateTint = 16843881; // 0x1010469
-    field public static final int indeterminateTintMode = 16843882; // 0x101046a
+    field public static final int indeterminateTint = 16843883; // 0x101046b
+    field public static final int indeterminateTintMode = 16843884; // 0x101046c
     field public static final int indicatorEnd = 16843730; // 0x10103d2
     field public static final int indicatorLeft = 16843021; // 0x101010d
     field public static final int indicatorRight = 16843022; // 0x101010e
@@ -712,7 +712,7 @@
     field public static final int innerRadiusRatio = 16843163; // 0x101019b
     field public static final deprecated int inputMethod = 16843112; // 0x1010168
     field public static final int inputType = 16843296; // 0x1010220
-    field public static final int inset = 16843958; // 0x10104b6
+    field public static final int inset = 16843960; // 0x10104b8
     field public static final int insetBottom = 16843194; // 0x10101ba
     field public static final int insetLeft = 16843191; // 0x10101b7
     field public static final int insetRight = 16843192; // 0x10101b8
@@ -786,8 +786,8 @@
     field public static final int largeScreens = 16843398; // 0x1010286
     field public static final int largestWidthLimitDp = 16843622; // 0x1010366
     field public static final int launchMode = 16842781; // 0x101001d
-    field public static final int launchTaskBehindBackgroundAnimation = 16843921; // 0x1010491
-    field public static final int launchTaskBehindSourceAnimation = 16843922; // 0x1010492
+    field public static final int launchTaskBehindBackgroundAnimation = 16843923; // 0x1010493
+    field public static final int launchTaskBehindSourceAnimation = 16843924; // 0x1010494
     field public static final int layerType = 16843604; // 0x1010354
     field public static final int layout = 16842994; // 0x10100f2
     field public static final int layoutAnimation = 16842988; // 0x10100ec
@@ -814,7 +814,7 @@
     field public static final int layout_centerVertical = 16843153; // 0x1010191
     field public static final int layout_column = 16843084; // 0x101014c
     field public static final int layout_columnSpan = 16843645; // 0x101037d
-    field public static final int layout_columnWeight = 16843865; // 0x1010459
+    field public static final int layout_columnWeight = 16843867; // 0x101045b
     field public static final int layout_gravity = 16842931; // 0x10100b3
     field public static final int layout_height = 16842997; // 0x10100f5
     field public static final int layout_margin = 16842998; // 0x10100f6
@@ -826,7 +826,7 @@
     field public static final int layout_marginTop = 16843000; // 0x10100f8
     field public static final int layout_row = 16843643; // 0x101037b
     field public static final int layout_rowSpan = 16843644; // 0x101037c
-    field public static final int layout_rowWeight = 16843864; // 0x1010458
+    field public static final int layout_rowWeight = 16843866; // 0x101045a
     field public static final int layout_scale = 16843155; // 0x1010193
     field public static final int layout_span = 16843085; // 0x101014d
     field public static final int layout_toEndOf = 16843704; // 0x10103b8
@@ -838,7 +838,7 @@
     field public static final int layout_x = 16843135; // 0x101017f
     field public static final int layout_y = 16843136; // 0x1010180
     field public static final int left = 16843181; // 0x10101ad
-    field public static final int letterSpacing = 16843959; // 0x10104b7
+    field public static final int letterSpacing = 16843961; // 0x10104b9
     field public static final int lineSpacingExtra = 16843287; // 0x1010217
     field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
     field public static final int lines = 16843092; // 0x1010154
@@ -866,7 +866,7 @@
     field public static final int manageSpaceActivity = 16842756; // 0x1010004
     field public static final int mapViewStyle = 16842890; // 0x101008a
     field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
-    field public static final int matchOrder = 16843855; // 0x101044f
+    field public static final int matchOrder = 16843857; // 0x1010451
     field public static final int max = 16843062; // 0x1010136
     field public static final int maxDate = 16843584; // 0x1010340
     field public static final int maxEms = 16843095; // 0x1010157
@@ -875,11 +875,11 @@
     field public static final int maxLength = 16843104; // 0x1010160
     field public static final int maxLevel = 16843186; // 0x10101b2
     field public static final int maxLines = 16843091; // 0x1010153
-    field public static final int maxRecents = 16843846; // 0x1010446
+    field public static final int maxRecents = 16843848; // 0x1010448
     field public static final int maxRows = 16843059; // 0x1010133
     field public static final int maxSdkVersion = 16843377; // 0x1010271
     field public static final int maxWidth = 16843039; // 0x101011f
-    field public static final int maximumAngle = 16843903; // 0x101047f
+    field public static final int maximumAngle = 16843905; // 0x1010481
     field public static final int measureAllChildren = 16843018; // 0x101010a
     field public static final int measureWithLargestChild = 16843476; // 0x10102d4
     field public static final int mediaRouteButtonStyle = 16843693; // 0x10103ad
@@ -895,19 +895,19 @@
     field public static final int minResizeWidth = 16843669; // 0x1010395
     field public static final int minSdkVersion = 16843276; // 0x101020c
     field public static final int minWidth = 16843071; // 0x101013f
-    field public static final int minimumHorizontalAngle = 16843901; // 0x101047d
-    field public static final int minimumVerticalAngle = 16843902; // 0x101047e
+    field public static final int minimumHorizontalAngle = 16843903; // 0x101047f
+    field public static final int minimumVerticalAngle = 16843904; // 0x1010480
     field public static final int mipMap = 16843725; // 0x10103cd
     field public static final int mirrorForRtl = 16843726; // 0x10103ce
     field public static final int mode = 16843134; // 0x101017e
     field public static final int moreIcon = 16843061; // 0x1010135
-    field public static final int multiArch = 16843918; // 0x101048e
+    field public static final int multiArch = 16843920; // 0x1010490
     field public static final int multiprocess = 16842771; // 0x1010013
     field public static final int name = 16842755; // 0x1010003
-    field public static final int navigationBarColor = 16843858; // 0x1010452
+    field public static final int navigationBarColor = 16843860; // 0x1010454
     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 nestedScrollingEnabled = 16843832; // 0x1010438
     field public static final int nextFocusDown = 16842980; // 0x10100e4
     field public static final int nextFocusForward = 16843580; // 0x101033c
     field public static final int nextFocusLeft = 16842977; // 0x10100e1
@@ -918,9 +918,9 @@
     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 numbersBackgroundColor = 16843939; // 0x10104a3
-    field public static final int numbersSelectorColor = 16843940; // 0x10104a4
-    field public static final int numbersTextColor = 16843938; // 0x10104a2
+    field public static final int numbersBackgroundColor = 16843941; // 0x10104a5
+    field public static final int numbersSelectorColor = 16843942; // 0x10104a6
+    field public static final int numbersTextColor = 16843940; // 0x10104a4
     field public static final deprecated int numeric = 16843109; // 0x1010165
     field public static final int numericShortcut = 16843236; // 0x10101e4
     field public static final int onClick = 16843375; // 0x101026f
@@ -935,14 +935,14 @@
     field public static final int overScrollFooter = 16843459; // 0x10102c3
     field public static final int overScrollHeader = 16843458; // 0x10102c2
     field public static final int overScrollMode = 16843457; // 0x10102c1
-    field public static final int overlapAnchor = 16843874; // 0x1010462
+    field public static final int overlapAnchor = 16843876; // 0x1010464
     field public static final int overridesImplicitlyEnabledSubtype = 16843682; // 0x10103a2
     field public static final int packageNames = 16843649; // 0x1010381
     field public static final int padding = 16842965; // 0x10100d5
     field public static final int paddingBottom = 16842969; // 0x10100d9
     field public static final int paddingEnd = 16843700; // 0x10103b4
     field public static final int paddingLeft = 16842966; // 0x10100d6
-    field public static final int paddingMode = 16843863; // 0x1010457
+    field public static final int paddingMode = 16843865; // 0x1010459
     field public static final int paddingRight = 16842968; // 0x10100d8
     field public static final int paddingStart = 16843699; // 0x10103b3
     field public static final int paddingTop = 16842967; // 0x10100d7
@@ -954,14 +954,14 @@
     field public static final int parentActivityName = 16843687; // 0x10103a7
     field public static final deprecated int password = 16843100; // 0x101015c
     field public static final int path = 16842794; // 0x101002a
-    field public static final int pathData = 16843807; // 0x101041f
+    field public static final int pathData = 16843808; // 0x1010420
     field public static final int pathPattern = 16842796; // 0x101002c
     field public static final int pathPrefix = 16842795; // 0x101002b
     field public static final int permission = 16842758; // 0x1010006
     field public static final int permissionFlags = 16843719; // 0x10103c7
     field public static final int permissionGroup = 16842762; // 0x101000a
     field public static final int permissionGroupFlags = 16843717; // 0x10103c5
-    field public static final int persistableMode = 16843821; // 0x101042d
+    field public static final int persistableMode = 16843823; // 0x101042f
     field public static final int persistent = 16842765; // 0x101000d
     field public static final int persistentDrawingCache = 16842990; // 0x10100ee
     field public static final deprecated int phoneNumber = 16843111; // 0x1010167
@@ -970,11 +970,11 @@
     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 popupElevation = 16843918; // 0x101048e
     field public static final int popupKeyboard = 16843331; // 0x1010243
     field public static final int popupLayout = 16843323; // 0x101023b
     field public static final int popupMenuStyle = 16843520; // 0x1010300
-    field public static final int popupTheme = 16843946; // 0x10104aa
+    field public static final int popupTheme = 16843948; // 0x10104ac
     field public static final int popupWindowStyle = 16842870; // 0x1010076
     field public static final int port = 16842793; // 0x1010029
     field public static final int positiveButtonText = 16843253; // 0x10101f5
@@ -989,8 +989,8 @@
     field public static final int privateImeOptions = 16843299; // 0x1010223
     field public static final int process = 16842769; // 0x1010011
     field public static final int progress = 16843063; // 0x1010137
-    field public static final int progressBackgroundTint = 16843877; // 0x1010465
-    field public static final int progressBackgroundTintMode = 16843878; // 0x1010466
+    field public static final int progressBackgroundTint = 16843879; // 0x1010467
+    field public static final int progressBackgroundTintMode = 16843880; // 0x1010468
     field public static final int progressBarPadding = 16843545; // 0x1010319
     field public static final int progressBarStyle = 16842871; // 0x1010077
     field public static final int progressBarStyleHorizontal = 16842872; // 0x1010078
@@ -1001,17 +1001,17 @@
     field public static final int progressBarStyleSmallInverse = 16843400; // 0x1010288
     field public static final int progressBarStyleSmallTitle = 16843279; // 0x101020f
     field public static final int progressDrawable = 16843068; // 0x101013c
-    field public static final int progressTint = 16843875; // 0x1010463
-    field public static final int progressTintMode = 16843876; // 0x1010464
+    field public static final int progressTint = 16843877; // 0x1010465
+    field public static final int progressTintMode = 16843878; // 0x1010466
     field public static final int prompt = 16843131; // 0x101017b
     field public static final int propertyName = 16843489; // 0x10102e1
-    field public static final int propertyXName = 16843892; // 0x1010474
-    field public static final int propertyYName = 16843893; // 0x1010475
+    field public static final int propertyXName = 16843894; // 0x1010476
+    field public static final int propertyYName = 16843895; // 0x1010477
     field public static final int protectionLevel = 16842761; // 0x1010009
     field public static final int publicKey = 16843686; // 0x10103a6
     field public static final int queryActionMsg = 16843227; // 0x10101db
     field public static final int queryAfterZeroResults = 16843394; // 0x1010282
-    field public static final int queryBackground = 16843911; // 0x1010487
+    field public static final int queryBackground = 16843913; // 0x1010489
     field public static final int queryHint = 16843608; // 0x1010358
     field public static final int quickContactBadgeStyleSmallWindowLarge = 16843443; // 0x10102b3
     field public static final int quickContactBadgeStyleSmallWindowMedium = 16843442; // 0x10102b2
@@ -1026,8 +1026,8 @@
     field public static final int ratingBarStyleIndicator = 16843280; // 0x1010210
     field public static final int ratingBarStyleSmall = 16842877; // 0x101007d
     field public static final int readPermission = 16842759; // 0x1010007
-    field public static final int recognitionService = 16843932; // 0x101049c
-    field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
+    field public static final int recognitionService = 16843934; // 0x101049e
+    field public static final int relinquishTaskIdentity = 16843896; // 0x1010478
     field public static final int repeatCount = 16843199; // 0x10101bf
     field public static final int repeatMode = 16843200; // 0x10101c0
     field public static final int reqFiveWayNav = 16843314; // 0x1010232
@@ -1039,7 +1039,7 @@
     field public static final int required = 16843406; // 0x101028e
     field public static final int requiredAccountType = 16843734; // 0x10103d6
     field public static final int requiredForAllUsers = 16843728; // 0x10103d0
-    field public static final int requiredForProfile = 16843816; // 0x1010428
+    field public static final int requiredForProfile = 16843818; // 0x101042a
     field public static final int requiresFadingEdge = 16843685; // 0x10103a5
     field public static final int requiresSmallestWidthDp = 16843620; // 0x1010364
     field public static final int resizeMode = 16843619; // 0x1010363
@@ -1048,8 +1048,8 @@
     field public static final int restoreAnyVersion = 16843450; // 0x10102ba
     field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d
     field public static final int restrictedAccountType = 16843733; // 0x10103d5
-    field public static final int restrictionType = 16843923; // 0x1010493
-    field public static final int reversible = 16843851; // 0x101044b
+    field public static final int restrictionType = 16843925; // 0x1010495
+    field public static final int reversible = 16843853; // 0x101044d
     field public static final int right = 16843183; // 0x10101af
     field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
     field public static final int ringtoneType = 16843257; // 0x10101f9
@@ -1089,7 +1089,7 @@
     field public static final int scrollbars = 16842974; // 0x10100de
     field public static final int scrollingCache = 16843006; // 0x10100fe
     field public static final deprecated int searchButtonText = 16843269; // 0x1010205
-    field public static final int searchIcon = 16843907; // 0x1010483
+    field public static final int searchIcon = 16843909; // 0x1010485
     field public static final int searchMode = 16843221; // 0x10101d5
     field public static final int searchSettingsDescription = 16843402; // 0x101028a
     field public static final int searchSuggestAuthority = 16843222; // 0x10101d6
@@ -1098,19 +1098,19 @@
     field public static final int searchSuggestPath = 16843223; // 0x10101d7
     field public static final int searchSuggestSelection = 16843224; // 0x10101d8
     field public static final int searchSuggestThreshold = 16843373; // 0x101026d
-    field public static final int searchViewStyle = 16843904; // 0x1010480
+    field public static final int searchViewStyle = 16843906; // 0x1010482
     field public static final int secondaryProgress = 16843064; // 0x1010138
-    field public static final int secondaryProgressTint = 16843879; // 0x1010467
-    field public static final int secondaryProgressTintMode = 16843880; // 0x1010468
+    field public static final int secondaryProgressTint = 16843881; // 0x1010469
+    field public static final int secondaryProgressTintMode = 16843882; // 0x101046a
     field public static final int seekBarStyle = 16842875; // 0x101007b
     field public static final int segmentedButtonStyle = 16843568; // 0x1010330
     field public static final int selectAllOnFocus = 16843102; // 0x101015e
     field public static final int selectable = 16843238; // 0x10101e6
     field public static final int selectableItemBackground = 16843534; // 0x101030e
-    field public static final int selectableItemBackgroundBorderless = 16843868; // 0x101045c
+    field public static final int selectableItemBackgroundBorderless = 16843870; // 0x101045e
     field public static final int selectedDateVerticalBar = 16843591; // 0x1010347
     field public static final int selectedWeekBackgroundColor = 16843586; // 0x1010342
-    field public static final int sessionService = 16843837; // 0x101043d
+    field public static final int sessionService = 16843839; // 0x101043f
     field public static final int settingsActivity = 16843301; // 0x1010225
     field public static final int setupActivity = 16843766; // 0x10103f6
     field public static final int shadowColor = 16843105; // 0x1010161
@@ -1127,13 +1127,13 @@
     field public static final int showDividers = 16843561; // 0x1010329
     field public static final int showOnLockScreen = 16843721; // 0x10103c9
     field public static final int showSilent = 16843259; // 0x10101fb
-    field public static final int showText = 16843950; // 0x10104ae
+    field public static final int showText = 16843952; // 0x10104b0
     field public static final int showWeekNumber = 16843582; // 0x101033e
     field public static final int shownWeekCount = 16843585; // 0x1010341
     field public static final int shrinkColumns = 16843082; // 0x101014a
     field public static final deprecated int singleLine = 16843101; // 0x101015d
     field public static final int singleUser = 16843711; // 0x10103bf
-    field public static final int slideEdge = 16843824; // 0x1010430
+    field public static final int slideEdge = 16843826; // 0x1010432
     field public static final int smallIcon = 16843422; // 0x101029e
     field public static final int smallScreens = 16843396; // 0x1010284
     field public static final int smoothScrollbar = 16843313; // 0x1010231
@@ -1145,19 +1145,19 @@
     field public static final int spinnerStyle = 16842881; // 0x1010081
     field public static final int spinnersShown = 16843595; // 0x101034b
     field public static final int splitMotionEvents = 16843503; // 0x10102ef
-    field public static final int splitTrack = 16843852; // 0x101044c
+    field public static final int splitTrack = 16843854; // 0x101044e
     field public static final int src = 16843033; // 0x1010119
     field public static final int ssp = 16843747; // 0x10103e3
     field public static final int sspPattern = 16843749; // 0x10103e5
     field public static final int sspPrefix = 16843748; // 0x10103e4
     field public static final int stackFromBottom = 16843005; // 0x10100fd
-    field public static final int stackViewStyle = 16843838; // 0x101043e
+    field public static final int stackViewStyle = 16843840; // 0x1010440
     field public static final int starStyle = 16842882; // 0x1010082
     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 deprecated int startYear = 16843132; // 0x101017c
-    field public static final int stateListAnimator = 16843848; // 0x1010448
+    field public static final int stateListAnimator = 16843850; // 0x101044a
     field public static final int stateNotNeeded = 16842774; // 0x1010016
     field public static final int state_above_anchor = 16842922; // 0x10100aa
     field public static final int state_accelerated = 16843547; // 0x101031b
@@ -1182,27 +1182,27 @@
     field public static final int state_single = 16842915; // 0x10100a3
     field public static final int state_window_focused = 16842909; // 0x101009d
     field public static final int staticWallpaperPreview = 16843569; // 0x1010331
-    field public static final int statusBarColor = 16843857; // 0x1010451
+    field public static final int statusBarColor = 16843859; // 0x1010453
     field public static final int stepSize = 16843078; // 0x1010146
     field public static final int stopWithTask = 16843626; // 0x101036a
     field public static final int streamType = 16843273; // 0x1010209
     field public static final int stretchColumns = 16843081; // 0x1010149
     field public static final int stretchMode = 16843030; // 0x1010116
-    field public static final int strokeColor = 16843808; // 0x1010420
-    field public static final int strokeLineCap = 16843813; // 0x1010425
-    field public static final int strokeLineJoin = 16843814; // 0x1010426
-    field public static final int strokeMiterLimit = 16843815; // 0x1010427
-    field public static final int strokeWidth = 16843809; // 0x1010421
-    field public static final int submitBackground = 16843912; // 0x1010488
+    field public static final int strokeColor = 16843809; // 0x1010421
+    field public static final int strokeLineCap = 16843815; // 0x1010427
+    field public static final int strokeLineJoin = 16843816; // 0x1010428
+    field public static final int strokeMiterLimit = 16843817; // 0x1010429
+    field public static final int strokeWidth = 16843811; // 0x1010423
+    field public static final int submitBackground = 16843914; // 0x101048a
     field public static final int subtitle = 16843473; // 0x10102d1
-    field public static final int subtitleTextAppearance = 16843823; // 0x101042f
+    field public static final int subtitleTextAppearance = 16843825; // 0x1010431
     field public static final int subtitleTextStyle = 16843513; // 0x10102f9
     field public static final int subtypeExtraValue = 16843674; // 0x101039a
     field public static final int subtypeId = 16843713; // 0x10103c1
     field public static final int subtypeLocale = 16843673; // 0x1010399
     field public static final int suggestActionMsg = 16843228; // 0x10101dc
     field public static final int suggestActionMsgColumn = 16843229; // 0x10101dd
-    field public static final int suggestionRowLayout = 16843910; // 0x1010486
+    field public static final int suggestionRowLayout = 16843912; // 0x1010488
     field public static final int summary = 16843241; // 0x10101e9
     field public static final int summaryColumn = 16843426; // 0x10102a2
     field public static final int summaryOff = 16843248; // 0x10101f0
@@ -1213,7 +1213,7 @@
     field public static final int switchMinWidth = 16843632; // 0x1010370
     field public static final int switchPadding = 16843633; // 0x1010371
     field public static final int switchPreferenceStyle = 16843629; // 0x101036d
-    field public static final int switchStyle = 16843839; // 0x101043f
+    field public static final int switchStyle = 16843841; // 0x1010441
     field public static final int switchTextAppearance = 16843630; // 0x101036e
     field public static final int switchTextOff = 16843628; // 0x101036c
     field public static final int switchTextOn = 16843627; // 0x101036b
@@ -1227,7 +1227,7 @@
     field public static final int targetClass = 16842799; // 0x101002f
     field public static final int targetDescriptions = 16843680; // 0x10103a0
     field public static final int targetId = 16843740; // 0x10103dc
-    field public static final int targetName = 16843853; // 0x101044d
+    field public static final int targetName = 16843855; // 0x101044f
     field public static final int targetPackage = 16842785; // 0x1010021
     field public static final int targetSdkVersion = 16843376; // 0x1010270
     field public static final int taskAffinity = 16842770; // 0x1010012
@@ -1251,7 +1251,7 @@
     field public static final int textAppearanceLargeInverse = 16842819; // 0x1010043
     field public static final int textAppearanceLargePopupMenu = 16843521; // 0x1010301
     field public static final int textAppearanceListItem = 16843678; // 0x101039e
-    field public static final int textAppearanceListItemSecondary = 16843826; // 0x1010432
+    field public static final int textAppearanceListItemSecondary = 16843828; // 0x1010434
     field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
     field public static final int textAppearanceMedium = 16842817; // 0x1010041
     field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
@@ -1308,38 +1308,38 @@
     field public static final int thumb = 16843074; // 0x1010142
     field public static final int thumbOffset = 16843075; // 0x1010143
     field public static final int thumbTextPadding = 16843634; // 0x1010372
-    field public static final int thumbTint = 16843889; // 0x1010471
-    field public static final int thumbTintMode = 16843890; // 0x1010472
+    field public static final int thumbTint = 16843891; // 0x1010473
+    field public static final int thumbTintMode = 16843892; // 0x1010474
     field public static final int thumbnail = 16843429; // 0x10102a5
     field public static final int tileMode = 16843265; // 0x1010201
-    field public static final int tileModeX = 16843895; // 0x1010477
-    field public static final int tileModeY = 16843896; // 0x1010478
-    field public static final int timePickerDialogTheme = 16843934; // 0x101049e
-    field public static final int timePickerMode = 16843957; // 0x10104b5
-    field public static final int timePickerStyle = 16843933; // 0x101049d
+    field public static final int tileModeX = 16843897; // 0x1010479
+    field public static final int tileModeY = 16843898; // 0x101047a
+    field public static final int timePickerDialogTheme = 16843936; // 0x10104a0
+    field public static final int timePickerMode = 16843959; // 0x10104b7
+    field public static final int timePickerStyle = 16843935; // 0x101049f
     field public static final int timeZone = 16843724; // 0x10103cc
     field public static final int tint = 16843041; // 0x1010121
     field public static final int tintMode = 16843797; // 0x1010415
     field public static final int title = 16843233; // 0x10101e1
     field public static final int titleCondensed = 16843234; // 0x10101e2
-    field public static final int titleTextAppearance = 16843822; // 0x101042e
+    field public static final int titleTextAppearance = 16843824; // 0x1010430
     field public static final int titleTextStyle = 16843512; // 0x10102f8
     field public static final int toAlpha = 16843211; // 0x10101cb
     field public static final int toDegrees = 16843188; // 0x10101b4
-    field public static final int toId = 16843849; // 0x1010449
+    field public static final int toId = 16843851; // 0x101044b
     field public static final int toScene = 16843742; // 0x10103de
     field public static final int toXDelta = 16843207; // 0x10101c7
     field public static final int toXScale = 16843203; // 0x10101c3
     field public static final int toYDelta = 16843209; // 0x10101c9
     field public static final int toYScale = 16843205; // 0x10101c5
-    field public static final int toolbarStyle = 16843947; // 0x10104ab
+    field public static final int toolbarStyle = 16843949; // 0x10104ad
     field public static final int top = 16843182; // 0x10101ae
     field public static final int topBright = 16842955; // 0x10100cb
     field public static final int topDark = 16842951; // 0x10100c7
     field public static final int topLeftRadius = 16843177; // 0x10101a9
     field public static final int topOffset = 16843352; // 0x1010258
     field public static final int topRightRadius = 16843178; // 0x10101aa
-    field public static final int touchscreenBlocksFocus = 16843919; // 0x101048f
+    field public static final int touchscreenBlocksFocus = 16843921; // 0x1010491
     field public static final int track = 16843631; // 0x101036f
     field public static final int transcriptMode = 16843008; // 0x1010100
     field public static final int transformPivotX = 16843552; // 0x1010320
@@ -1348,14 +1348,14 @@
     field public static final int transitionGroup = 16843803; // 0x101041b
     field public static final int transitionName = 16843802; // 0x101041a
     field public static final int transitionOrdering = 16843744; // 0x10103e0
-    field public static final int translateX = 16843866; // 0x101045a
-    field public static final int translateY = 16843867; // 0x101045b
+    field public static final int translateX = 16843868; // 0x101045c
+    field public static final int translateY = 16843869; // 0x101045d
     field public static final int translationX = 16843554; // 0x1010322
     field public static final int translationY = 16843555; // 0x1010323
     field public static final int translationZ = 16843796; // 0x1010414
-    field public static final int trimPathEnd = 16843811; // 0x1010423
-    field public static final int trimPathOffset = 16843812; // 0x1010424
-    field public static final int trimPathStart = 16843810; // 0x1010422
+    field public static final int trimPathEnd = 16843813; // 0x1010425
+    field public static final int trimPathOffset = 16843814; // 0x1010426
+    field public static final int trimPathStart = 16843812; // 0x1010424
     field public static final int type = 16843169; // 0x10101a1
     field public static final int typeface = 16842902; // 0x1010096
     field public static final int uiOptions = 16843672; // 0x1010398
@@ -1383,10 +1383,10 @@
     field public static final int viewportHeight = 16843805; // 0x101041d
     field public static final int viewportWidth = 16843804; // 0x101041c
     field public static final int visibility = 16842972; // 0x10100dc
-    field public static final int visibilityMode = 16843900; // 0x101047c
+    field public static final int visibilityMode = 16843902; // 0x101047e
     field public static final int visible = 16843156; // 0x1010194
     field public static final int vmSafeMode = 16843448; // 0x10102b8
-    field public static final int voiceIcon = 16843908; // 0x1010484
+    field public static final int voiceIcon = 16843910; // 0x1010486
     field public static final int voiceLanguage = 16843349; // 0x1010255
     field public static final int voiceLanguageModel = 16843347; // 0x1010253
     field public static final int voiceMaxResults = 16843350; // 0x1010256
@@ -1412,23 +1412,23 @@
     field public static final int windowActionBar = 16843469; // 0x10102cd
     field public static final int windowActionBarOverlay = 16843492; // 0x10102e4
     field public static final int windowActionModeOverlay = 16843485; // 0x10102dd
-    field public static final int windowAllowEnterTransitionOverlap = 16843836; // 0x101043c
-    field public static final int windowAllowExitTransitionOverlap = 16843835; // 0x101043b
+    field public static final int windowAllowEnterTransitionOverlap = 16843838; // 0x101043e
+    field public static final int windowAllowExitTransitionOverlap = 16843837; // 0x101043d
     field public static final int windowAnimationStyle = 16842926; // 0x10100ae
     field public static final int windowBackground = 16842836; // 0x1010054
-    field public static final int windowClipToOutline = 16843948; // 0x10104ac
+    field public static final int windowClipToOutline = 16843950; // 0x10104ae
     field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
     field public static final int windowContentOverlay = 16842841; // 0x1010059
     field public static final int windowContentTransitionManager = 16843795; // 0x1010413
     field public static final int windowContentTransitions = 16843794; // 0x1010412
     field public static final int windowDisablePreview = 16843298; // 0x1010222
-    field public static final int windowDrawsSystemBarBackgrounds = 16843856; // 0x1010450
-    field public static final int windowElevation = 16843920; // 0x1010490
+    field public static final int windowDrawsSystemBarBackgrounds = 16843858; // 0x1010452
+    field public static final int windowElevation = 16843922; // 0x1010492
     field public static final int windowEnableSplitTouch = 16843543; // 0x1010317
     field public static final int windowEnterAnimation = 16842932; // 0x10100b4
-    field public static final int windowEnterTransition = 16843831; // 0x1010437
+    field public static final int windowEnterTransition = 16843833; // 0x1010439
     field public static final int windowExitAnimation = 16842933; // 0x10100b5
-    field public static final int windowExitTransition = 16843832; // 0x1010438
+    field public static final int windowExitTransition = 16843834; // 0x101043a
     field public static final int windowFrame = 16842837; // 0x1010055
     field public static final int windowFullscreen = 16843277; // 0x101020d
     field public static final int windowHideAnimation = 16842935; // 0x10100b7
@@ -1439,12 +1439,12 @@
     field public static final int windowNoDisplay = 16843294; // 0x101021e
     field public static final int windowNoTitle = 16842838; // 0x1010056
     field public static final int windowOverscan = 16843727; // 0x10103cf
-    field public static final int windowReenterTransition = 16843952; // 0x10104b0
-    field public static final int windowReturnTransition = 16843951; // 0x10104af
-    field public static final int windowSharedElementEnterTransition = 16843833; // 0x1010439
-    field public static final int windowSharedElementExitTransition = 16843834; // 0x101043a
-    field public static final int windowSharedElementReenterTransition = 16843954; // 0x10104b2
-    field public static final int windowSharedElementReturnTransition = 16843953; // 0x10104b1
+    field public static final int windowReenterTransition = 16843954; // 0x10104b2
+    field public static final int windowReturnTransition = 16843953; // 0x10104b1
+    field public static final int windowSharedElementEnterTransition = 16843835; // 0x101043b
+    field public static final int windowSharedElementExitTransition = 16843836; // 0x101043c
+    field public static final int windowSharedElementReenterTransition = 16843956; // 0x10104b4
+    field public static final int windowSharedElementReturnTransition = 16843955; // 0x10104b3
     field public static final int windowShowAnimation = 16842934; // 0x10100b6
     field public static final int windowShowWallpaper = 16843410; // 0x1010292
     field public static final int windowSoftInputMode = 16843307; // 0x101022b
@@ -1452,15 +1452,15 @@
     field public static final int windowTitleBackgroundStyle = 16842844; // 0x101005c
     field public static final int windowTitleSize = 16842842; // 0x101005a
     field public static final int windowTitleStyle = 16842843; // 0x101005b
-    field public static final int windowTransitionBackgroundFadeDuration = 16843873; // 0x1010461
+    field public static final int windowTransitionBackgroundFadeDuration = 16843875; // 0x1010463
     field public static final int windowTranslucentNavigation = 16843760; // 0x10103f0
     field public static final int windowTranslucentStatus = 16843759; // 0x10103ef
     field public static final int writePermission = 16842760; // 0x1010008
     field public static final int x = 16842924; // 0x10100ac
     field public static final int xlargeScreens = 16843455; // 0x10102bf
     field public static final int y = 16842925; // 0x10100ad
-    field public static final int yearListItemTextAppearance = 16843929; // 0x1010499
-    field public static final int yearListSelectorColor = 16843930; // 0x101049a
+    field public static final int yearListItemTextAppearance = 16843931; // 0x101049b
+    field public static final int yearListSelectorColor = 16843932; // 0x101049c
     field public static final int yesNoPreferenceStyle = 16842896; // 0x1010090
     field public static final int zAdjustment = 16843201; // 0x10101c1
   }
@@ -25887,8 +25887,10 @@
     field public static final java.lang.String ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
     field public static final java.lang.String ACTION_SOUND_SETTINGS = "android.settings.SOUND_SETTINGS";
     field public static final java.lang.String ACTION_SYNC_SETTINGS = "android.settings.SYNC_SETTINGS";
+    field public static final java.lang.String ACTION_USAGE_ACCESS_SETTINGS = "android.settings.USAGE_ACCESS_SETTINGS";
     field public static final java.lang.String ACTION_USER_DICTIONARY_SETTINGS = "android.settings.USER_DICTIONARY_SETTINGS";
     field public static final java.lang.String ACTION_VOICE_CONTROL_AIRPLANE_MODE = "android.settings.VOICE_CONTROL_AIRPLANE_MODE";
+    field public static final java.lang.String ACTION_VOICE_INPUT_SETTINGS = "android.settings.VOICE_INPUT_SETTINGS";
     field public static final java.lang.String ACTION_WIFI_IP_SETTINGS = "android.settings.WIFI_IP_SETTINGS";
     field public static final java.lang.String ACTION_WIFI_SETTINGS = "android.settings.WIFI_SETTINGS";
     field public static final java.lang.String ACTION_WIRELESS_SETTINGS = "android.settings.WIRELESS_SETTINGS";
@@ -30814,6 +30816,7 @@
   public static class InputFilter.LengthFilter implements android.text.InputFilter {
     ctor public InputFilter.LengthFilter(int);
     method public java.lang.CharSequence filter(java.lang.CharSequence, int, int, android.text.Spanned, int, int);
+    method public int getMax();
   }
 
   public abstract interface InputType {
@@ -32622,6 +32625,7 @@
     method public void setTo(android.util.DisplayMetrics);
     method public void setToDefaults();
     field public static final int DENSITY_400 = 400; // 0x190
+    field public static final int DENSITY_560 = 560; // 0x230
     field public static final int DENSITY_DEFAULT = 160; // 0xa0
     field public static final int DENSITY_HIGH = 240; // 0xf0
     field public static final int DENSITY_LOW = 120; // 0x78
@@ -36047,6 +36051,7 @@
     method public android.view.accessibility.AccessibilityNodeInfo getLabelFor();
     method public android.view.accessibility.AccessibilityNodeInfo getLabeledBy();
     method public int getLiveRegion();
+    method public int getMaxTextLength();
     method public int getMovementGranularities();
     method public java.lang.CharSequence getPackageName();
     method public android.view.accessibility.AccessibilityNodeInfo getParent();
@@ -36110,6 +36115,7 @@
     method public void setLabeledBy(android.view.View, int);
     method public void setLiveRegion(int);
     method public void setLongClickable(boolean);
+    method public void setMaxTextLength(int);
     method public void setMovementGranularities(int);
     method public void setMultiLine(boolean);
     method public void setPackageName(java.lang.CharSequence);
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index c5e91e3..15152e5 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -1703,6 +1703,10 @@
             throw new IllegalArgumentException("Missing ABI argument");
         }
 
+        if ("-".equals(abi)) {
+            return abi;
+        }
+
         final String[] supportedAbis = Build.SUPPORTED_ABIS;
         for (String supportedAbi : supportedAbis) {
             if (supportedAbi.equals(abi)) {
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 311a8f55..a11149e 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1942,9 +1942,9 @@
             return true;
         }
 
-        case DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION: {
+        case KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION: {
             data.enforceInterface(IActivityManager.descriptor);
-            dismissKeyguardOnNextActivity();
+            keyguardWaitingForActivityDrawn();
             reply.writeNoException();
             return true;
         }
@@ -4738,11 +4738,11 @@
         reply.recycle();
     }
 
-    public void dismissKeyguardOnNextActivity() throws RemoteException {
+    public void keyguardWaitingForActivityDrawn() throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
         data.writeInterfaceToken(IActivityManager.descriptor);
-        mRemote.transact(DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION, data, reply, 0);
+        mRemote.transact(KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION, data, reply, 0);
         reply.readException();
         data.recycle();
         reply.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 772e132..4464a67 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -383,7 +383,7 @@
 
     public void showBootMessage(CharSequence msg, boolean always) throws RemoteException;
 
-    public void dismissKeyguardOnNextActivity() throws RemoteException;
+    public void keyguardWaitingForActivityDrawn() throws RemoteException;
 
     public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity)
             throws RemoteException;
@@ -688,7 +688,6 @@
     int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
     int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
     int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
-    int DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+138;
     int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139;
     int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140;
     int REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+141;
@@ -760,4 +759,5 @@
     int NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+228;
     int START_ACTIVITY_FROM_RECENTS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 229;
     int NOTIFY_ENTER_ANIMATION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+230;
+    int KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+231;
 }
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index c3619eb..5f58839 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -2577,9 +2577,21 @@
         }
 
         private RemoteViews applyStandardTemplate(int resId, boolean fitIn1U) {
+            final boolean largeFontScale
+                    = mContext.getResources().getConfiguration().fontScale >= 1.25f;
+
             Bitmap profileIcon = getProfileBadge();
             RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(),
                     mOriginatingUserId, resId);
+
+            if (largeFontScale) {
+                // Make a little extra room for the bigger text.
+                final int margin = (int) mContext.getResources()
+                        .getDimensionPixelSize(R.dimen.notification_large_font_vert_pad);
+                contentView.setViewPadding(R.id.line1, 0, margin, 0, 0);
+                contentView.setViewPadding(R.id.line3, 0, 0, 0, margin);
+            }
+
             boolean showLine3 = false;
             boolean showLine2 = false;
 
@@ -3221,7 +3233,7 @@
         }
 
         private int getBigTextLayoutResource() {
-            return R.layout.notification_template_material_big_text;
+            return getBigBaseLayoutResource();
         }
 
         private int getInboxLayoutResource() {
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index db87cf7..44bf35d 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -4256,6 +4256,16 @@
         public ArraySet<String> mUpgradeKeySets;
         public ArrayMap<String, ArraySet<PublicKey>> mKeySetMapping;
 
+        /**
+         * The install time abi override for this package, if any.
+         *
+         * TODO: This seems like a horrible place to put the abiOverride because
+         * this isn't something the packageParser parsers. However, this fits in with
+         * the rest of the PackageManager where package scanning randomly pushes
+         * and prods fields out of {@code this.applicationInfo}.
+         */
+        public String cpuAbiOverride;
+
         public Package(String packageName) {
             this.packageName = packageName;
             applicationInfo.packageName = packageName;
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index 129248c..a4ec80c 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -49,9 +49,8 @@
 public final class RouteInfo implements Parcelable {
     /**
      * The IP destination address for this route.
-     * TODO: Make this an IpPrefix.
      */
-    private final LinkAddress mDestination;
+    private final IpPrefix mDestination;
 
     /**
      * The gateway address for this route.
@@ -81,26 +80,15 @@
      * @param gateway the IP address to route packets through
      * @param iface the interface name to send packets on
      *
-     * TODO: Convert to use IpPrefix.
-     *
      * @hide
      */
     public RouteInfo(IpPrefix destination, InetAddress gateway, String iface) {
-        this(destination == null ? null :
-                new LinkAddress(destination.getAddress(), destination.getPrefixLength()),
-                gateway, iface);
-    }
-
-    /**
-     * @hide
-     */
-    public RouteInfo(LinkAddress destination, InetAddress gateway, String iface) {
         if (destination == null) {
             if (gateway != null) {
                 if (gateway instanceof Inet4Address) {
-                    destination = new LinkAddress(Inet4Address.ANY, 0);
+                    destination = new IpPrefix(Inet4Address.ANY, 0);
                 } else {
-                    destination = new LinkAddress(Inet6Address.ANY, 0);
+                    destination = new IpPrefix(Inet6Address.ANY, 0);
                 }
             } else {
                 // no destination, no gateway. invalid.
@@ -108,6 +96,9 @@
                                                    destination);
             }
         }
+        // TODO: set mGateway to null if there is no gateway. This is more correct, saves space, and
+        // matches the documented behaviour. Before we can do this we need to fix all callers (e.g.,
+        // ConnectivityService) to stop doing things like r.getGateway().equals(), ... .
         if (gateway == null) {
             if (destination.getAddress() instanceof Inet4Address) {
                 gateway = Inet4Address.ANY;
@@ -117,20 +108,28 @@
         }
         mHasGateway = (!gateway.isAnyLocalAddress());
 
-        mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
-                destination.getPrefixLength()), destination.getPrefixLength());
         if ((destination.getAddress() instanceof Inet4Address &&
                  (gateway instanceof Inet4Address == false)) ||
                 (destination.getAddress() instanceof Inet6Address &&
                  (gateway instanceof Inet6Address == false))) {
             throw new IllegalArgumentException("address family mismatch in RouteInfo constructor");
         }
-        mGateway = gateway;
-        mInterface = iface;
+        mDestination = destination;  // IpPrefix objects are immutable.
+        mGateway = gateway;          // InetAddress objects are immutable.
+        mInterface = iface;          // Strings are immutable.
         mIsHost = isHost();
     }
 
     /**
+     * @hide
+     */
+    public RouteInfo(LinkAddress destination, InetAddress gateway, String iface) {
+        this(destination == null ? null :
+                new IpPrefix(destination.getAddress(), destination.getPrefixLength()),
+                gateway, iface);
+    }
+
+    /**
      * Constructs a {@code RouteInfo} object.
      *
      * If destination is null, then gateway must be specified and the
@@ -164,7 +163,7 @@
      * @hide
      */
     public RouteInfo(InetAddress gateway) {
-        this((LinkAddress) null, gateway, null);
+        this((IpPrefix) null, gateway, null);
     }
 
     /**
@@ -200,9 +199,9 @@
         if (host == null) return null;
 
         if (host instanceof Inet4Address) {
-            return new RouteInfo(new LinkAddress(host, 32), gateway, iface);
+            return new RouteInfo(new IpPrefix(host, 32), gateway, iface);
         } else {
-            return new RouteInfo(new LinkAddress(host, 128), gateway, iface);
+            return new RouteInfo(new IpPrefix(host, 128), gateway, iface);
         }
     }
 
@@ -219,7 +218,7 @@
      * @return {@link IpPrefix} specifying the destination.  This is never {@code null}.
      */
     public IpPrefix getDestination() {
-        return new IpPrefix(mDestination.getAddress(), mDestination.getPrefixLength());
+        return mDestination;
     }
 
     /**
@@ -227,7 +226,7 @@
      * @hide
      */
     public LinkAddress getDestinationLinkAddress() {
-        return mDestination;
+        return new LinkAddress(mDestination.getAddress(), mDestination.getPrefixLength());
     }
 
     /**
@@ -363,7 +362,7 @@
 
         RouteInfo target = (RouteInfo) obj;
 
-        return Objects.equals(mDestination, target.getDestinationLinkAddress()) &&
+        return Objects.equals(mDestination, target.getDestination()) &&
                 Objects.equals(mGateway, target.getGateway()) &&
                 Objects.equals(mInterface, target.getInterface());
     }
@@ -388,16 +387,9 @@
      * Implement the Parcelable interface
      */
     public void writeToParcel(Parcel dest, int flags) {
-        dest.writeByteArray(mDestination.getAddress().getAddress());
-        dest.writeInt(mDestination.getPrefixLength());
-
-        if (mGateway == null) {
-            dest.writeByte((byte) 0);
-        } else {
-            dest.writeByte((byte) 1);
-            dest.writeByteArray(mGateway.getAddress());
-        }
-
+        dest.writeParcelable(mDestination, flags);
+        byte[] gatewayBytes = (mGateway == null) ? null : mGateway.getAddress();
+        dest.writeByteArray(gatewayBytes);
         dest.writeString(mInterface);
     }
 
@@ -407,33 +399,16 @@
     public static final Creator<RouteInfo> CREATOR =
         new Creator<RouteInfo>() {
         public RouteInfo createFromParcel(Parcel in) {
-            InetAddress destAddr = null;
-            int prefix = 0;
+            IpPrefix dest = in.readParcelable(null);
+
             InetAddress gateway = null;
-
             byte[] addr = in.createByteArray();
-            prefix = in.readInt();
-
             try {
-                destAddr = InetAddress.getByAddress(addr);
+                gateway = InetAddress.getByAddress(addr);
             } catch (UnknownHostException e) {}
 
-            if (in.readByte() == 1) {
-                addr = in.createByteArray();
-
-                try {
-                    gateway = InetAddress.getByAddress(addr);
-                } catch (UnknownHostException e) {}
-            }
-
             String iface = in.readString();
 
-            LinkAddress dest = null;
-
-            if (destAddr != null) {
-                dest = new LinkAddress(destAddr, prefix);
-            }
-
             return new RouteInfo(dest, gateway, iface);
         }
 
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 55ba9e9..9a41e20 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -170,6 +170,20 @@
             "android.settings.ACCESSIBILITY_SETTINGS";
 
     /**
+     * Activity Action: Show settings to control access to usage information.
+     * <p>
+     * In some cases, a matching Activity may not exist, so ensure you
+     * safeguard against this.
+     * <p>
+     * Input: Nothing.
+     * <p>
+     * Output: Nothing.
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_USAGE_ACCESS_SETTINGS =
+            "android.settings.USAGE_ACCESS_SETTINGS";
+
+    /**
      * Activity Action: Show settings to allow configuration of security and
      * location privacy.
      * <p>
@@ -372,6 +386,21 @@
      * Output: Nothing.
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_VOICE_INPUT_SETTINGS =
+            "android.settings.VOICE_INPUT_SETTINGS";
+
+    /**
+     * Activity Action: Show settings to configure input methods, in particular
+     * allowing the user to enable input methods.
+     * <p>
+     * In some cases, a matching Activity may not exist, so ensure you
+     * safeguard against this.
+     * <p>
+     * Input: Nothing.
+     * <p>
+     * Output: Nothing.
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_INPUT_METHOD_SETTINGS =
             "android.settings.INPUT_METHOD_SETTINGS";
 
@@ -6343,7 +6372,7 @@
 
         /**
          * Milliseconds to wait before bouncing Wi-Fi after settings is restored. Note that after
-         * the caller is done with this, they should call {@link ContentResolver#delete(Uri)} to
+         * the caller is done with this, they should call {@link ContentResolver#delete} to
          * clean up any value that they may have written.
          *
          * @hide
diff --git a/core/java/android/service/voice/VoiceInteractionServiceInfo.java b/core/java/android/service/voice/VoiceInteractionServiceInfo.java
index bacda04..e6e9413 100644
--- a/core/java/android/service/voice/VoiceInteractionServiceInfo.java
+++ b/core/java/android/service/voice/VoiceInteractionServiceInfo.java
@@ -99,6 +99,11 @@
                 mParseError = "No sessionService specified";
                 return;
             }
+            /* Not yet time
+            if (mRecognitionService == null) {
+                mParseError = "No recogitionService specified";
+                return;
+            } */
         } catch (XmlPullParserException e) {
             mParseError = "Error parsing voice interation service meta-data: " + e;
             Log.w(TAG, "error parsing voice interaction service meta-data", e);
diff --git a/core/java/android/text/InputFilter.java b/core/java/android/text/InputFilter.java
index 8d4b08e..bff09a2 100644
--- a/core/java/android/text/InputFilter.java
+++ b/core/java/android/text/InputFilter.java
@@ -75,14 +75,15 @@
      * greater than the specified length.
      */
     public static class LengthFilter implements InputFilter {
+        private final int mMax;
+
         public LengthFilter(int max) {
             mMax = max;
         }
 
-        public CharSequence filter(CharSequence source, int start, int end,
-                                   Spanned dest, int dstart, int dend) {
+        public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
+                int dstart, int dend) {
             int keep = mMax - (dest.length() - (dend - dstart));
-
             if (keep <= 0) {
                 return "";
             } else if (keep >= end - start) {
@@ -99,6 +100,11 @@
             }
         }
 
-        private int mMax;
+        /**
+         * @return the maximum length enforced by this input filter
+         */
+        public int getMax() {
+            return mMax;
+        }
     }
 }
diff --git a/core/java/android/util/ArrayMap.java b/core/java/android/util/ArrayMap.java
index 9a0b7fc..3bdd58a 100644
--- a/core/java/android/util/ArrayMap.java
+++ b/core/java/android/util/ArrayMap.java
@@ -410,7 +410,7 @@
 
     /**
      * Add a new value to the array map.
-     * @param key The key under which to store the value.  <b>Must not be null.</b>  If
+     * @param key The key under which to store the value.  If
      * this key already exists in the array, its value will be replaced.
      * @param value The value to store for the given key.
      * @return Returns the old value that was stored for the given key, or null if there
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index 3f10b92..946a3f7 100644
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -68,7 +68,7 @@
 
     /**
      * Intermediate density for screens that sit somewhere between
-     * {@link #DENSITY_XHIGH} (320dpi) and {@link #DENSITY_XXHIGH} (480 dpi).
+     * {@link #DENSITY_XHIGH} (320 dpi) and {@link #DENSITY_XXHIGH} (480 dpi).
      * This is not a density that applications should target, instead relying
      * on the system to scale their {@link #DENSITY_XXHIGH} assets for them.
      */
@@ -80,6 +80,14 @@
     public static final int DENSITY_XXHIGH = 480;
 
     /**
+     * Intermediate density for screens that sit somewhere between
+     * {@link #DENSITY_XXHIGH} (480 dpi) and {@link #DENSITY_XXXHIGH} (560 dpi).
+     * This is not a density that applications should target, instead relying
+     * on the system to scale their {@link #DENSITY_XXXHIGH} assets for them.
+     */
+    public static final int DENSITY_560 = 560;
+
+    /**
      * Standard quantized DPI for extra-extra-extra-high-density screens.  Applications
      * should not generally worry about this density; relying on XHIGH graphics
      * being scaled up to it should be sufficient for almost all cases.  A typical
diff --git a/core/java/android/view/GhostView.java b/core/java/android/view/GhostView.java
index a79838f..3cbaf60 100644
--- a/core/java/android/view/GhostView.java
+++ b/core/java/android/view/GhostView.java
@@ -17,6 +17,7 @@
 
 import android.graphics.Canvas;
 import android.graphics.Matrix;
+import android.widget.FrameLayout;
 
 /**
  * This view draws another View in an Overlay without changing the parent. It will not be drawn
@@ -28,17 +29,13 @@
  */
 public class GhostView extends View {
     private final View mView;
+    private int mReferences;
 
-    private GhostView(View view, ViewGroup host, Matrix matrix) {
+    private GhostView(View view) {
         super(view.getContext());
         mView = view;
         mView.mGhostView = this;
-        mRenderNode.setAnimationMatrix(matrix);
         final ViewGroup parent = (ViewGroup) mView.getParent();
-        setLeft(0);
-        setTop(0);
-        setRight(host.getWidth());
-        setBottom(host.getHeight());
         setGhostedVisibility(View.INVISIBLE);
         parent.mRecreateDisplayList = true;
         parent.getDisplayList();
@@ -100,10 +97,13 @@
         ViewGroupOverlay overlay = viewGroup.getOverlay();
         ViewOverlay.OverlayViewGroup overlayViewGroup = overlay.mOverlayViewGroup;
         GhostView ghostView = view.mGhostView;
+        int previousRefCount = 0;
         if (ghostView != null) {
-            ViewGroup oldParent = (ViewGroup) ghostView.getParent();
-            if (oldParent != overlayViewGroup) {
-                oldParent.removeView(ghostView);
+            View oldParent = (View) ghostView.getParent();
+            ViewGroup oldGrandParent = (ViewGroup) oldParent.getParent();
+            if (oldGrandParent != overlayViewGroup) {
+                previousRefCount = ghostView.mReferences;
+                oldGrandParent.removeView(oldParent);
                 ghostView = null;
             }
         }
@@ -112,9 +112,19 @@
                 matrix = new Matrix();
                 calculateMatrix(view, viewGroup, matrix);
             }
-            ghostView = new GhostView(view, (ViewGroup) overlayViewGroup.mHostView, matrix);
-            overlay.add(ghostView);
+            ghostView = new GhostView(view);
+            ghostView.setMatrix(matrix);
+            FrameLayout parent = new FrameLayout(view.getContext());
+            parent.setClipChildren(false);
+            copySize(viewGroup, parent);
+            copySize(viewGroup, ghostView);
+            parent.addView(ghostView);
+            overlay.add(parent);
+            ghostView.mReferences = previousRefCount;
+        } else if (matrix != null) {
+            ghostView.setMatrix(matrix);
         }
+        ghostView.mReferences++;
         return ghostView;
     }
 
@@ -125,12 +135,23 @@
     public static void removeGhost(View view) {
         GhostView ghostView = view.mGhostView;
         if (ghostView != null) {
-            ViewGroup parent = (ViewGroup) ghostView.getParent();
-            parent.removeView(ghostView);
+            ghostView.mReferences--;
+            if (ghostView.mReferences == 0) {
+                ViewGroup parent = (ViewGroup) ghostView.getParent();
+                ViewGroup grandParent = (ViewGroup) parent.getParent();
+                grandParent.removeView(parent);
+            }
         }
     }
 
     public static GhostView getGhost(View view) {
         return view.mGhostView;
     }
+
+    private static void copySize(View from, View to) {
+        to.setLeft(0);
+        to.setTop(0);
+        to.setRight(from.getWidth());
+        to.setBottom(from.getHeight());
+    }
 }
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index 0b15ba7..4d9a8cc 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -1107,8 +1107,7 @@
 
                     exportUnrolledArray(context, out, property, array, valuePrefix, suffix);
 
-                    // Probably want to return here, same as for fields.
-                    return;
+                    continue;
                 } else if (!returnType.isPrimitive()) {
                     if (property.deepExport()) {
                         dumpViewProperties(context, methodValue, out, prefix + property.prefix());
@@ -1187,8 +1186,7 @@
 
                     exportUnrolledArray(context, out, property, array, valuePrefix, suffix);
 
-                    // We exit here!
-                    return;
+                    continue;
                 } else if (!type.isPrimitive()) {
                     if (property.deepExport()) {
                         dumpViewProperties(context, field.get(view), out, prefix +
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index b6c650d..a7e02e4 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -1014,6 +1014,11 @@
     public void dismissKeyguardLw();
 
     /**
+     * Notifies the keyguard that the activity has drawn it was waiting for.
+     */
+    public void notifyActivityDrawnForKeyguardLw();
+
+    /**
      * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
      * returns true as soon as we know that Keyguard is disabled.
      *
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java
index 4f34231..ca6437a 100644
--- a/core/java/android/view/accessibility/AccessibilityCache.java
+++ b/core/java/android/view/accessibility/AccessibilityCache.java
@@ -36,7 +36,7 @@
 
     private static final boolean DEBUG = false;
 
-    private static final boolean CHECK_INTEGRITY = Build.IS_DEBUGGABLE;
+    private static final boolean CHECK_INTEGRITY = "eng".equals(Build.TYPE);
 
     private final Object mLock = new Object();
 
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 1bf4639..3987fbc 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -562,6 +562,7 @@
     private LongArray mChildNodeIds;
     private ArrayList<AccessibilityAction> mActions;
 
+    private int mMaxTextLength = -1;
     private int mMovementGranularities;
 
     private int mTextSelectionStart = UNDEFINED_SELECTION_INDEX;
@@ -1045,6 +1046,36 @@
     }
 
     /**
+     * Sets the maximum text length, or -1 for no limit.
+     * <p>
+     * Typically used to indicate that an editable text field has a limit on
+     * the number of characters entered.
+     * <p>
+     * <strong>Note:</strong> Cannot be called from an
+     * {@link android.accessibilityservice.AccessibilityService}.
+     * This class is made immutable before being delivered to an AccessibilityService.
+     *
+     * @param max The maximum text length.
+     * @see #getMaxTextLength()
+     *
+     * @throws IllegalStateException If called from an AccessibilityService.
+     */
+    public void setMaxTextLength(int max) {
+        enforceNotSealed();
+        mMaxTextLength = max;
+    }
+
+    /**
+     * Returns the maximum text length for this node.
+     *
+     * @return The maximum text length, or -1 for no limit.
+     * @see #setMaxTextLength(int)
+     */
+    public int getMaxTextLength() {
+        return mMaxTextLength;
+    }
+
+    /**
      * Sets the movement granularities for traversing the text of this node.
      * <p>
      *   <strong>Note:</strong> Cannot be called from an
@@ -2469,8 +2500,8 @@
             parcel.writeInt(0);
         }
 
+        parcel.writeInt(mMaxTextLength);
         parcel.writeInt(mMovementGranularities);
-
         parcel.writeInt(mBooleanProperties);
 
         parcel.writeCharSequence(mPackageName);
@@ -2562,6 +2593,7 @@
         }
 
         mBooleanProperties = other.mBooleanProperties;
+        mMaxTextLength = other.mMaxTextLength;
         mMovementGranularities = other.mMovementGranularities;
 
         final LongArray otherChildNodeIds = other.mChildNodeIds;
@@ -2636,8 +2668,8 @@
             }
         }
 
+        mMaxTextLength = parcel.readInt();
         mMovementGranularities = parcel.readInt();
-
         mBooleanProperties = parcel.readInt();
 
         mPackageName = parcel.readCharSequence();
@@ -2695,6 +2727,7 @@
         mLabeledById = ROOT_NODE_ID;
         mWindowId = UNDEFINED_ITEM_ID;
         mConnectionId = UNDEFINED_CONNECTION_ID;
+        mMaxTextLength = -1;
         mMovementGranularities = 0;
         if (mChildNodeIds != null) {
             mChildNodeIds.clear();
@@ -2911,6 +2944,7 @@
         builder.append("; className: ").append(mClassName);
         builder.append("; text: ").append(mText);
         builder.append("; error: ").append(mError);
+        builder.append("; maxTextLength: ").append(mMaxTextLength);
         builder.append("; contentDescription: ").append(mContentDescription);
         builder.append("; viewIdResName: ").append(mViewIdResourceName);
 
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 623b5f9..eec3570 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -1655,7 +1655,12 @@
             final boolean isImmediate = (mCursorAnchorInfoMonitorMode &
                     CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
             if (!isImmediate && Objects.equals(mCursorAnchorInfo, cursorAnchorInfo)) {
-                Log.w(TAG, "Ignoring redundant updateCursorAnchorInfo: info=" + cursorAnchorInfo);
+                // TODO: Consider always emitting this message once we have addressed redundant
+                // calls of this method from android.widget.Editor.
+                if (DEBUG) {
+                    Log.w(TAG, "Ignoring redundant updateCursorAnchorInfo: info="
+                            + cursorAnchorInfo);
+                }
                 return;
             }
             if (DEBUG) Log.v(TAG, "updateCursorAnchorInfo: " + cursorAnchorInfo);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b162e54..a536b2d 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8392,6 +8392,15 @@
             }
         }
 
+        // Check for known input filter types.
+        final int numFilters = mFilters.length;
+        for (int i = 0; i < numFilters; i++) {
+            final InputFilter filter = mFilters[i];
+            if (filter instanceof InputFilter.LengthFilter) {
+                info.setMaxTextLength(((InputFilter.LengthFilter) filter).getMax());
+            }
+        }
+
         if (!isSingleLine()) {
             info.setMultiLine(true);
         }
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl
index a5421f5..64f3bea 100644
--- a/core/java/com/android/internal/policy/IKeyguardService.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardService.aidl
@@ -65,4 +65,10 @@
      * @param fadeoutDuration the duration of the exit animation, in milliseconds
      */
     oneway void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
+
+    /**
+     * Notifies the Keyguard that the activity that was starting has now been drawn and it's safe
+     * to start the keyguard dismiss sequence.
+     */
+    oneway void onActivityDrawn();
 }
diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp
index eaadfb2..a728455 100644
--- a/core/jni/android_hardware_camera2_DngCreator.cpp
+++ b/core/jni/android_hardware_camera2_DngCreator.cpp
@@ -428,7 +428,7 @@
 
 status_t InputStripSource::writeToStream(Output& stream, uint32_t count) {
     status_t err = OK;
-    uint32_t fullSize = mRowStride * mHeight;
+    uint32_t fullSize = mWidth * mHeight * mBytesPerSample * mSamplesPerPixel;
     jlong offset = mOffset;
 
     if (fullSize != count) {
@@ -560,7 +560,7 @@
 DirectStripSource::~DirectStripSource() {}
 
 status_t DirectStripSource::writeToStream(Output& stream, uint32_t count) {
-    uint32_t fullSize = mRowStride * mHeight;
+    uint32_t fullSize = mWidth * mHeight * mBytesPerSample * mSamplesPerPixel;
 
     if (fullSize != count) {
         ALOGE("%s: Amount to write %u doesn't match image size %u", __FUNCTION__, count,
diff --git a/core/res/res/anim/wallpaper_close_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml
index 981923a..a189813 100644
--- a/core/res/res/anim/wallpaper_close_enter.xml
+++ b/core/res/res/anim/wallpaper_close_enter.xml
@@ -18,15 +18,17 @@
 -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
-        android:shareInterpolator="false" android:zAdjustment="top">
-    <scale android:fromXScale=".2" android:toXScale="1.0"
-            android:fromYScale=".2" android:toYScale="1.0"
-            android:pivotX="50%p" android:pivotY="50%p"
-            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
-            android:interpolator="@interpolator/decelerate_cubic"
-            android:duration="300" />
+    android:background="#ff000000" android:shareInterpolator="false" android:zAdjustment="top">
+
     <alpha android:fromAlpha="0" android:toAlpha="1.0"
-            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
-            android:interpolator="@interpolator/decelerate_cubic"
-            android:duration="300"/>
+        android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
+        android:interpolator="@interpolator/decelerate_quart"
+        android:startOffset="300"
+        android:duration="167"/>
+
+    <translate android:fromYDelta="110%" android:toYDelta="0"
+        android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
+        android:interpolator="@interpolator/decelerate_quint"
+        android:startOffset="300"
+        android:duration="417" />
 </set>
\ No newline at end of file
diff --git a/core/res/res/anim/wallpaper_close_exit.xml b/core/res/res/anim/wallpaper_close_exit.xml
index a91eb49..12b31aef 100644
--- a/core/res/res/anim/wallpaper_close_exit.xml
+++ b/core/res/res/anim/wallpaper_close_exit.xml
@@ -20,5 +20,5 @@
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:detachWallpaper="true" android:shareInterpolator="false" android:zAdjustment="normal">
     <alpha android:fromAlpha="1.0" android:toAlpha="1.0"
-            android:duration="300" />
+            android:duration="417" />
 </set>
\ No newline at end of file
diff --git a/core/res/res/layout/notification_material_action.xml b/core/res/res/layout/notification_material_action.xml
index 7ccaad5..8f8c4fb 100644
--- a/core/res/res/layout/notification_material_action.xml
+++ b/core/res/res/layout/notification_material_action.xml
@@ -21,11 +21,12 @@
     android:layout_width="0dp"
     android:layout_height="48dp"
     android:layout_weight="1"
+    android:layout_margin="0dp"
     android:gravity="start|center_vertical"
     android:drawablePadding="8dp"
     android:paddingStart="8dp"
     android:textColor="#555555"
-    android:textSize="14dp"
+    android:textSize="@dimen/notification_text_size"
     android:singleLine="true"
     android:ellipsize="end"
     />
diff --git a/core/res/res/layout/notification_material_action_tombstone.xml b/core/res/res/layout/notification_material_action_tombstone.xml
index 8bf456e..976448b 100644
--- a/core/res/res/layout/notification_material_action_tombstone.xml
+++ b/core/res/res/layout/notification_material_action_tombstone.xml
@@ -25,7 +25,7 @@
     android:drawablePadding="8dp"
     android:paddingStart="8dp"
     android:textColor="#555555"
-    android:textSize="14dp"
+    android:textSize="@dimen/notification_text_size"
     android:singleLine="true"
     android:ellipsize="end"
     android:alpha="0.5"
diff --git a/core/res/res/layout/notification_template_material_base.xml b/core/res/res/layout/notification_template_material_base.xml
index ab13b98..5e51db9 100644
--- a/core/res/res/layout/notification_template_material_base.xml
+++ b/core/res/res/layout/notification_template_material_base.xml
@@ -29,106 +29,27 @@
         />
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-
-        android:layout_gravity="fill_vertical"
+        android:layout_height="match_parent"
+        android:layout_gravity="top"
+        android:layout_marginEnd="8dp"
         android:layout_marginStart="@dimen/notification_large_icon_width"
         android:minHeight="@dimen/notification_large_icon_height"
         android:orientation="vertical"
-        android:paddingEnd="8dp"
-        android:paddingTop="2dp"
-        android:paddingBottom="2dp"
-        android:gravity="top"
         >
-        <LinearLayout
-            android:id="@+id/line1"
+        <include layout="@layout/notification_template_part_line1"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingTop="6dp"
-            android:layout_marginStart="8dp"
-            android:orientation="horizontal"
-            >
-            <TextView android:id="@+id/title"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Title"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:singleLine="true"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal"
-                android:layout_weight="1"
-                />
-            <ViewStub android:id="@+id/time"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_weight="0"
-                android:visibility="gone"
-                android:layout="@layout/notification_template_part_time"
-                />
-            <ViewStub android:id="@+id/chronometer"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_weight="0"
-                android:visibility="gone"
-                android:layout="@layout/notification_template_part_chronometer"
-                />
-        </LinearLayout>
-        <TextView android:id="@+id/text2"
-            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="-2dp"
-            android:layout_marginBottom="-2dp"
-            android:layout_marginStart="8dp"
-            android:singleLine="true"
-            android:fadingEdge="horizontal"
-            android:ellipsize="marquee"
-            android:visibility="gone"
+            android:layout_weight="1"
             />
-        <ProgressBar
-            android:id="@android:id/progress"
-            android:layout_width="match_parent"
-            android:layout_height="12dp"
-            android:layout_marginStart="8dp"
-            android:visibility="gone"
-            style="@style/Widget.StatusBar.Material.ProgressBar"
-            />
-        <LinearLayout
-            android:id="@+id/line3"
+        <include layout="@layout/notification_template_part_line2"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:gravity="center_vertical"
-            android:layout_marginStart="8dp"
-            >
-            <TextView android:id="@+id/text"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_gravity="center"
-                android:singleLine="true"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal"
-                />
-            <TextView android:id="@+id/info"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Info"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:singleLine="true"
-                android:gravity="center"
-                android:paddingStart="8dp"
-                />
-            <ImageView android:id="@+id/profile_icon"
-                android:layout_width="24dp"
-                android:layout_height="24dp"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:layout_marginStart="8dp"
-                android:scaleType="centerInside"
-                android:visibility="gone"
-                />
-        </LinearLayout>
+            android:layout_weight="1"
+            />
+        <include layout="@layout/notification_template_part_line3"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            />
     </LinearLayout>
 </FrameLayout>
diff --git a/core/res/res/layout/notification_template_material_big_base.xml b/core/res/res/layout/notification_template_material_big_base.xml
index 0564a8f..2243a09 100644
--- a/core/res/res/layout/notification_template_material_big_base.xml
+++ b/core/res/res/layout/notification_template_material_big_base.xml
@@ -30,124 +30,24 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_gravity="fill_vertical"
+        android:layout_gravity="top"
+        android:layout_marginEnd="8dp"
+        android:layout_marginStart="@dimen/notification_large_icon_width"
         android:minHeight="@dimen/notification_large_icon_height"
         android:orientation="vertical"
-        android:gravity="top"
         >
-        <LinearLayout
+        <include layout="@layout/notification_template_part_line1" />
+        <include layout="@layout/notification_template_part_line2" />
+        <TextView android:id="@+id/big_text"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/notification_large_icon_width"
             android:minHeight="@dimen/notification_large_icon_height"
-            android:paddingTop="2dp"
-            android:orientation="vertical"
-            >
-            <LinearLayout
-                android:id="@+id/line1"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingTop="6dp"
-                android:layout_marginEnd="8dp"
-                android:layout_marginStart="8dp"
-                android:orientation="horizontal"
-                >
-                <TextView android:id="@+id/title"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Title"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:singleLine="true"
-                    android:ellipsize="marquee"
-                    android:fadingEdge="horizontal"
-                    android:layout_weight="1"
-                    />
-                <ViewStub android:id="@+id/time"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_time"
-                    />
-                <ViewStub android:id="@+id/chronometer"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_chronometer"
-                    />
-            </LinearLayout>
-            <TextView android:id="@+id/text2"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="-2dp"
-                android:layout_marginBottom="-2dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:fadingEdge="horizontal"
-                android:ellipsize="marquee"
-                android:visibility="gone"
-                />
-            <TextView android:id="@+id/big_text"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="false"
-                android:visibility="gone"
-                />
-            <LinearLayout
-                android:id="@+id/line3"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:orientation="horizontal"
-                android:gravity="center_vertical"
-                >
-                <TextView android:id="@+id/text"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:layout_gravity="center"
-                    android:singleLine="true"
-                    android:ellipsize="marquee"
-                    android:fadingEdge="horizontal"
-                    />
-                <TextView android:id="@+id/info"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Info"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="center"
-                    android:layout_weight="0"
-                    android:singleLine="true"
-                    android:gravity="center"
-                    android:paddingStart="8dp"
-                    />
-                <ImageView android:id="@+id/profile_icon"
-                    android:layout_width="24dp"
-                    android:layout_height="24dp"
-                    android:layout_gravity="center"
-                    android:layout_weight="0"
-                    android:layout_marginStart="8dp"
-                    android:scaleType="centerInside"
-                    android:visibility="gone"
-                    />
-            </LinearLayout>
-            <ProgressBar
-                android:id="@android:id/progress"
-                android:layout_width="match_parent"
-                android:layout_height="12dp"
-                android:layout_marginBottom="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:visibility="gone"
-                style="@style/Widget.StatusBar.Material.ProgressBar"
-                />
-        </LinearLayout>
+            android:layout_weight="1"
+            android:singleLine="false"
+            android:visibility="gone"
+            />
+        <include layout="@layout/notification_template_part_line3" />
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="1dp"
@@ -156,9 +56,10 @@
             android:background="@drawable/list_divider_holo_light" />
         <include
             layout="@layout/notification_material_action_list"
+            android:layout_marginLeft="-8dp"
+            android:layout_marginRight="-8dp"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/notification_large_icon_width"
             />
     </LinearLayout>
 </FrameLayout>
diff --git a/core/res/res/layout/notification_template_material_big_picture.xml b/core/res/res/layout/notification_template_material_big_picture.xml
index 74819fd..302e651 100644
--- a/core/res/res/layout/notification_template_material_big_picture.xml
+++ b/core/res/res/layout/notification_template_material_big_picture.xml
@@ -40,13 +40,13 @@
         />
     <include layout="@layout/notification_template_material_base"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="64dp"
         />
   <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="208dp"
-        android:paddingStart="64dp"
+        android:paddingStart="@dimen/notification_large_icon_width"
         android:layout_gravity="bottom"
         android:background="#CCEEEEEE"
         >
diff --git a/core/res/res/layout/notification_template_material_big_text.xml b/core/res/res/layout/notification_template_material_big_text.xml
deleted file mode 100644
index 1de5add..0000000
--- a/core/res/res/layout/notification_template_material_big_text.xml
+++ /dev/null
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2014 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:internal="http://schemas.android.com/apk/prv/res/android"
-    android:id="@+id/status_bar_latest_event_content"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    internal:layout_minHeight="65dp"
-    internal:layout_maxHeight="unbounded"
-    >
-    <include layout="@layout/notification_template_icon_group"
-        android:layout_width="@dimen/notification_large_icon_width"
-        android:layout_height="@dimen/notification_large_icon_height"
-        />
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="fill_vertical"
-        android:layout_marginStart="@dimen/notification_large_icon_width"
-        android:orientation="vertical"
-        android:paddingTop="0dp"
-        android:paddingBottom="2dp"
-        android:gravity="top"
-        >
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:minHeight="@dimen/notification_large_icon_height"
-            android:orientation="vertical"
-            android:layout_marginStart="8dp"
-            android:layout_marginEnd="8dp"
-            android:layout_weight="1"
-            >
-            <LinearLayout
-                android:id="@+id/line1"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingTop="8dp"
-                android:orientation="horizontal"
-                android:layout_gravity="top"
-                android:layout_weight="0"
-                >
-                <TextView android:id="@+id/title"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Title"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:singleLine="true"
-                    android:ellipsize="marquee"
-                    android:fadingEdge="horizontal"
-                    android:layout_weight="1"
-                    />
-                <ViewStub android:id="@+id/time"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_time"
-                    />
-                <ViewStub android:id="@+id/chronometer"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_chronometer"
-                    />
-            </LinearLayout>
-            <TextView android:id="@+id/text2"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="-2dp"
-                android:layout_marginBottom="-2dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:fadingEdge="horizontal"
-                android:ellipsize="marquee"
-                android:layout_weight="0"
-                android:visibility="gone"
-                />
-            <ProgressBar
-                android:id="@android:id/progress"
-                android:layout_width="match_parent"
-                android:layout_height="12dp"
-                android:layout_marginBottom="8dp"
-                android:layout_marginEnd="8dp"
-                android:visibility="gone"
-                android:layout_weight="0"
-                style="@style/Widget.StatusBar.Material.ProgressBar"
-                />
-            <TextView android:id="@+id/big_text"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginBottom="10dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="false"
-                android:visibility="gone"
-                android:maxLines="8"
-                android:ellipsize="end"
-                android:layout_weight="1"
-                />
-        </LinearLayout>
-        <ImageView
-            android:layout_width="match_parent"
-            android:layout_height="1dip"
-            android:id="@+id/action_divider"
-            android:visibility="gone"
-            android:background="@drawable/list_divider_holo_light" />
-        <include
-            layout="@layout/notification_material_action_list"
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:visibility="gone"
-            android:layout_weight="1"
-            />
-        <ImageView
-            android:layout_width="match_parent"
-            android:layout_height="1dp"
-            android:id="@+id/overflow_divider"
-            android:layout_marginBottom="8dp"
-            android:visibility="visible"
-            android:background="@drawable/list_divider_holo_light" />
-        <LinearLayout
-            android:id="@+id/line3"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginStart="8dp"
-            android:layout_marginBottom="8dp"
-            android:layout_marginEnd="8dp"
-            android:orientation="horizontal"
-            android:layout_weight="0"
-            android:gravity="center_vertical"
-            >
-            <TextView android:id="@+id/text"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_gravity="center"
-                android:singleLine="true"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal"
-                />
-            <TextView android:id="@+id/info"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Info"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:singleLine="true"
-                android:gravity="center"
-                android:paddingStart="8dp"
-                />
-            <ImageView android:id="@+id/profile_icon"
-                android:layout_width="24dp"
-                android:layout_height="24dp"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:layout_marginStart="8dp"
-                android:scaleType="centerInside"
-                android:visibility="gone"
-                />
-        </LinearLayout>
-    </LinearLayout>
-</FrameLayout>
diff --git a/core/res/res/layout/notification_template_material_inbox.xml b/core/res/res/layout/notification_template_material_inbox.xml
index 8411ff5..6133791 100644
--- a/core/res/res/layout/notification_template_material_inbox.xml
+++ b/core/res/res/layout/notification_template_material_inbox.xml
@@ -30,175 +30,93 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_gravity="fill_vertical"
+        android:layout_gravity="top"
         android:layout_marginStart="@dimen/notification_large_icon_width"
         android:minHeight="@dimen/notification_large_icon_height"
         android:orientation="vertical"
-        android:paddingTop="0dp"
-        android:paddingBottom="2dp"
-        android:gravity="top"
         >
-        <LinearLayout
+        <include layout="@layout/notification_template_part_line1" />
+        <include layout="@layout/notification_template_part_line2" />
+        <TextView android:id="@+id/inbox_text0"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:minHeight="@dimen/notification_large_icon_height"
-            android:paddingTop="2dp"
-            android:orientation="vertical"
-            >
-            <LinearLayout
-                android:id="@+id/line1"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:paddingTop="6dp"
-                android:orientation="horizontal"
-                android:layout_weight="0"
-                >
-                <TextView android:id="@+id/title"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Title"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:singleLine="true"
-                    android:ellipsize="marquee"
-                    android:fadingEdge="horizontal"
-                    android:layout_weight="1"
-                    />
-                <ViewStub android:id="@+id/time"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_time"
-                    />
-                <ViewStub android:id="@+id/chronometer"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0"
-                    android:visibility="gone"
-                    android:layout="@layout/notification_template_part_chronometer"
-                    />
-            </LinearLayout>
-            <TextView android:id="@+id/text2"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="-2dp"
-                android:layout_marginBottom="-2dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:fadingEdge="horizontal"
-                android:ellipsize="marquee"
-                android:visibility="gone"
-                android:layout_weight="0"
-                />
-            <ProgressBar
-                android:id="@android:id/progress"
-                android:layout_width="match_parent"
-                android:layout_height="12dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:visibility="gone"
-                android:layout_weight="0"
-                style="@style/Widget.Material.Light.ProgressBar.Horizontal"
-                />
-            <TextView android:id="@+id/inbox_text0"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text1"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text2"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text3"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text4"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text5"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_text6"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                />
-            <TextView android:id="@+id/inbox_more"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:visibility="gone"
-                android:layout_weight="1"
-                android:text="@android:string/ellipsis"
-                />
-            <FrameLayout
-                android:id="@+id/inbox_end_pad"
-                android:layout_width="match_parent"
-                android:layout_height="8dip"
-                android:visibility="gone"
-                android:layout_weight="0"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
             />
-        </LinearLayout>
+        <TextView android:id="@+id/inbox_text1"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_text2"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_text3"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_text4"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_text5"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_text6"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            />
+        <TextView android:id="@+id/inbox_more"
+            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:visibility="gone"
+            android:layout_weight="1"
+            android:text="@android:string/ellipsis"
+            />
+        <FrameLayout
+            android:id="@+id/inbox_end_pad"
+            android:layout_width="match_parent"
+            android:layout_height="8dip"
+            android:visibility="gone"
+            android:layout_weight="0"
+        />
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="1dip"
@@ -209,6 +127,8 @@
             layout="@layout/notification_material_action_list"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginLeft="-8dp"
+            android:layout_marginRight="-8dp"
             android:layout_weight="0"
             />
         <ImageView
@@ -217,47 +137,6 @@
             android:id="@+id/overflow_divider"
             android:visibility="visible"
             android:background="@drawable/list_divider_holo_light" />
-        <LinearLayout
-            android:id="@+id/line3"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="8dp"
-            android:layout_marginStart="8dp"
-            android:layout_marginBottom="8dp"
-            android:layout_marginEnd="8dp"
-            android:orientation="horizontal"
-            android:layout_weight="0"
-            android:gravity="center_vertical"
-            >
-            <TextView android:id="@+id/text"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_gravity="center"
-                android:singleLine="true"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal"
-                />
-            <TextView android:id="@+id/info"
-                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Info"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:singleLine="true"
-                android:gravity="center"
-                android:paddingStart="8dp"
-                />
-            <ImageView android:id="@+id/profile_icon"
-                android:layout_width="24dp"
-                android:layout_height="24dp"
-                android:layout_gravity="center"
-                android:layout_weight="0"
-                android:layout_marginStart="8dp"
-                android:scaleType="centerInside"
-                android:visibility="gone"
-                />
-        </LinearLayout>
+        <include layout="@layout/notification_template_part_line3" />
     </LinearLayout>
 </FrameLayout>
diff --git a/core/res/res/layout/notification_template_part_line1.xml b/core/res/res/layout/notification_template_part_line1.xml
new file mode 100644
index 0000000..d652959
--- /dev/null
+++ b/core/res/res/layout/notification_template_part_line1.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2014 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/line1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:paddingTop="@dimen/notification_vert_pad"
+    android:layout_weight="0"
+    >
+    <TextView android:id="@+id/title"
+        android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:fadingEdge="horizontal"
+        android:layout_weight="1"
+        />
+    <ViewStub android:id="@+id/time"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:visibility="gone"
+        android:layout="@layout/notification_template_part_time"
+        />
+    <ViewStub android:id="@+id/chronometer"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:visibility="gone"
+        android:layout="@layout/notification_template_part_chronometer"
+        />
+</LinearLayout>
diff --git a/core/res/res/layout/notification_template_part_line2.xml b/core/res/res/layout/notification_template_part_line2.xml
new file mode 100644
index 0000000..1e19df1
--- /dev/null
+++ b/core/res/res/layout/notification_template_part_line2.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2014 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+    <TextView 
+        android:id="@+id/text2"
+        android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="-2dp"
+        android:layout_marginBottom="-2dp"
+        android:singleLine="true"
+        android:fadingEdge="horizontal"
+        android:ellipsize="marquee"
+        android:visibility="gone"
+        android:layout_weight="0"
+        />
+    <ProgressBar
+        android:id="@android:id/progress"
+        android:layout_width="match_parent"
+        android:layout_height="8dp"
+        android:visibility="gone"
+        android:layout_weight="0"
+        style="@style/Widget.Material.Light.ProgressBar.Horizontal"
+        />
+</merge>
diff --git a/core/res/res/layout/notification_template_part_line3.xml b/core/res/res/layout/notification_template_part_line3.xml
new file mode 100644
index 0000000..2c8c704c
--- /dev/null
+++ b/core/res/res/layout/notification_template_part_line3.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2014 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/line3"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:layout_weight="0"
+    android:gravity="center_vertical"
+    android:paddingBottom="@dimen/notification_vert_pad"
+    >
+    <TextView android:id="@+id/text"
+        android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:layout_gravity="center"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:fadingEdge="horizontal"
+        />
+    <TextView android:id="@+id/info"
+        android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Info"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:layout_weight="0"
+        android:singleLine="true"
+        android:gravity="center"
+        android:paddingStart="8dp"
+        />
+    <ImageView android:id="@+id/profile_icon"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_gravity="center"
+        android:layout_weight="0"
+        android:layout_marginStart="8dp"
+        android:scaleType="centerInside"
+        android:visibility="gone"
+        />
+</LinearLayout>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index e81ec69..3e18a25 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5209,10 +5209,14 @@
         <attr name="name" />
         <!-- The width a path stroke -->
         <attr name="strokeWidth" format="float" />
+        <!-- The opacity of a path stroke @hide-->
+        <attr name="strokeOpacity" format="float" />
         <!-- The color to stroke the path if not defined implies no stroke-->
         <attr name="strokeColor" format="color" />
         <!-- The color to fill the path if not defined implies no fill-->
         <attr name="fillColor" format="color" />
+        <!-- The level of opacity of the filled area of the path @hide-->
+        <attr name="fillOpacity" format="float" />
         <!-- The specification of the operations that define the path  -->
         <attr name="pathData" format="string" />
         <!-- The fraction of the path to trim from the start from 0 to 1 -->
@@ -6851,9 +6855,11 @@
          its {@link android.service.voice.VoiceInteractionService#SERVICE_META_DATA} meta-data entry.
          Described here are the attributes that can be included in that tag. -->
     <declare-styleable name="VoiceInteractionService">
-        <!-- The service that hosts active voice interaction sessions. -->
+        <!-- The service that hosts active voice interaction sessions.  This is required. -->
         <attr name="sessionService" format="string" />
-        <!-- The service that provides voice recognition. -->
+        <!-- The service that provides voice recognition.  This is required.  When the user
+             selects this voice interaction service, they will also be implicitly selecting
+             the component here for their recognition service. -->
         <attr name="recognitionService" format="string" />
         <attr name="settingsActivity" />
     </declare-styleable>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index bacdc3f..9d6c36d 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -42,11 +42,6 @@
     <dimen name="status_bar_icon_size">24dip</dimen>
     <!-- Size of the giant number (unread count) in the notifications -->
     <dimen name="status_bar_content_number_size">48sp</dimen>
-    <!-- Height of the system bar (combined status & navigation); used by
-         SystemUI internally, not respected by the window manager. -->
-    <dimen name="system_bar_height">@dimen/navigation_bar_height</dimen>
-    <!-- Height of notification icons in the system bar -->
-    <dimen name="system_bar_icon_size">32dip</dimen>
     <!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
     <dimen name="status_bar_edge_ignore">5dp</dimen>
 
@@ -220,11 +215,17 @@
     <dimen name="action_bar_stacked_tab_max_width">180dp</dimen>
 
     <!-- Size of notification text (see TextAppearance.StatusBar.EventContent) -->
-    <dimen name="notification_text_size">13dp</dimen>
+    <dimen name="notification_text_size">13sp</dimen>
     <!-- Size of notification text titles (see TextAppearance.StatusBar.EventContent.Title) -->
-    <dimen name="notification_title_text_size">16dp</dimen>
+    <dimen name="notification_title_text_size">16sp</dimen>
     <!-- Size of smaller notification text (see TextAppearance.StatusBar.EventContent.Line2, Info, Time) -->
-    <dimen name="notification_subtext_size">12dp</dimen>
+    <dimen name="notification_subtext_size">12sp</dimen>
+
+    <!-- 8dp at the top/bottom of the notification view -->
+    <dimen name="notification_vert_pad">10dp</dimen>
+
+    <!-- Replacement for @dimen/notification_vert_pad when the text is large -->
+    <dimen name="notification_large_font_vert_pad">3dp</dimen>
 
     <!-- Keyguard dimensions -->
     <!-- TEMP -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 60aacf2..67352d7 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2118,9 +2118,11 @@
   <public type="attr" name="transitionGroup" />
   <public type="attr" name="viewportWidth" />
   <public type="attr" name="viewportHeight" />
+  <public type="attr" name="fillOpacity" />
   <public type="attr" name="fillColor" />
   <public type="attr" name="pathData" />
   <public type="attr" name="strokeColor" />
+  <public type="attr" name="strokeOpacity" />
   <public type="attr" name="strokeWidth" />
   <public type="attr" name="trimPathStart" />
   <public type="attr" name="trimPathEnd" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 35baf9c..8fc9bac 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1360,7 +1360,7 @@
         <item name="lightZ">800dp</item>
         <item name="lightRadius">800dp</item>
         <item name="ambientShadowAlpha">0.06</item>
-        <item name="spotShadowAlpha">0.22</item>
+        <item name="spotShadowAlpha">0.16</item>
     </style>
 
 </resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 0ebf0b5..eaacedd 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -349,6 +349,7 @@
   <java-symbol type="dimen" name="notification_text_size" />
   <java-symbol type="dimen" name="notification_title_text_size" />
   <java-symbol type="dimen" name="notification_subtext_size" />
+  <java-symbol type="dimen" name="notification_large_font_vert_pad" />
   <java-symbol type="dimen" name="immersive_mode_cling_width" />
   <java-symbol type="dimen" name="circular_display_mask_offset" />
 
@@ -1699,7 +1700,6 @@
   <java-symbol type="layout" name="notification_template_material_base" />
   <java-symbol type="layout" name="notification_template_material_big_base" />
   <java-symbol type="layout" name="notification_template_material_big_picture" />
-  <java-symbol type="layout" name="notification_template_material_big_text" />
   <java-symbol type="layout" name="notification_template_material_inbox" />
   <java-symbol type="layout" name="notification_template_material_media" />
   <java-symbol type="layout" name="notification_template_material_big_media" />
@@ -1725,7 +1725,6 @@
 
   <java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
   <java-symbol type="dimen" name="status_bar_icon_size" />
-  <java-symbol type="dimen" name="system_bar_icon_size" />
   <java-symbol type="drawable" name="list_selector_pressed_holo_dark" />
   <java-symbol type="drawable" name="scrubber_control_disabled_holo" />
   <java-symbol type="drawable" name="scrubber_control_selector_holo" />
diff --git a/core/tests/coretests/src/android/net/RouteInfoTest.java b/core/tests/coretests/src/android/net/RouteInfoTest.java
index dcacd11..0b88bc7 100644
--- a/core/tests/coretests/src/android/net/RouteInfoTest.java
+++ b/core/tests/coretests/src/android/net/RouteInfoTest.java
@@ -214,6 +214,29 @@
       assertFalse(r.isIPv6Default());
     }
 
+    public void testTruncation() {
+      LinkAddress l;
+      RouteInfo r;
+
+      l = new LinkAddress("192.0.2.5/30");
+      r = new RouteInfo(l, Address("192.0.2.1"), "wlan0");
+      assertEquals("192.0.2.4", r.getDestination().getAddress().getHostAddress());
+
+      l = new LinkAddress("2001:db8:1:f::5/63");
+      r = new RouteInfo(l, Address("2001:db8:5::1"), "wlan0");
+      assertEquals("2001:db8:1:e::", r.getDestination().getAddress().getHostAddress());
+    }
+
+    // Make sure that creating routes to multicast addresses doesn't throw an exception. Even though
+    // there's nothing we can do with them, we don't want to crash if, e.g., someone calls
+    // requestRouteToHostAddress("230.0.0.0", MOBILE_HIPRI);
+    public void testMulticastRoute() {
+      RouteInfo r;
+      r = new RouteInfo(Prefix("230.0.0.0/32"), Address("192.0.2.1"), "wlan0");
+      r = new RouteInfo(Prefix("ff02::1/128"), Address("2001:db8::1"), "wlan0");
+      // No exceptions? Good.
+    }
+
     public RouteInfo passThroughParcel(RouteInfo r) {
         Parcel p = Parcel.obtain();
         RouteInfo r2 = null;
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index 0dc903a..06586ca 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -132,6 +132,9 @@
      * @return The best matching typeface.
      */
     public static Typeface create(Typeface family, int style) {
+        if (style < 0 || style > 3) {
+            style = 0;
+        }
         long ni = 0;
         if (family != null) {
             // Return early if we're asked for the same face/style
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index f097239..ea9f732 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -157,6 +157,12 @@
     private boolean mOverrideBounds;
 
     /**
+     * Whether hotspots are being cleared. Used to prevent re-entry by
+     * animation finish listeners.
+     */
+    private boolean mClearingHotspots;
+
+    /**
      * Constructor used for drawable inflation.
      */
     RippleDrawable() {
@@ -524,6 +530,8 @@
     }
 
     private void clearHotspots() {
+        mClearingHotspots = true;
+
         final int count = mAnimatingRipplesCount;
         final Ripple[] ripples = mAnimatingRipples;
         for (int i = 0; i < count; i++) {
@@ -532,11 +540,6 @@
             final Ripple ripple = ripples[i];
             ripples[i] = null;
             ripple.cancel();
-
-            // The active ripple may also be animating. Don't cancel it twice.
-            if (mRipple == ripple) {
-                mRipple = null;
-            }
         }
 
         if (mRipple != null) {
@@ -549,6 +552,7 @@
             mBackground = null;
         }
 
+        mClearingHotspots = false;
         mAnimatingRipplesCount = 0;
         invalidateSelf();
     }
@@ -647,15 +651,17 @@
      * @param ripple the ripple to remove
      */
     void removeRipple(Ripple ripple) {
-        // Ripple ripple ripple ripple. Ripple ripple.
-        final Ripple[] ripples = mAnimatingRipples;
-        final int count = mAnimatingRipplesCount;
-        final int index = getRippleIndex(ripple);
-        if (index >= 0) {
-            System.arraycopy(ripples, index + 1, ripples, index + 1 - 1, count - (index + 1));
-            ripples[count - 1] = null;
-            mAnimatingRipplesCount--;
-            invalidateSelf();
+        if (!mClearingHotspots) {
+            // Ripple ripple ripple ripple. Ripple ripple.
+            final Ripple[] ripples = mAnimatingRipples;
+            final int count = mAnimatingRipplesCount;
+            final int index = getRippleIndex(ripple);
+            if (index >= 0) {
+                System.arraycopy(ripples, index + 1, ripples, index + 1 - 1, count - (index + 1));
+                ripples[count - 1] = null;
+                mAnimatingRipplesCount--;
+                invalidateSelf();
+            }
         }
     }
 
diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp
index 181230a..9cc83ed 100644
--- a/libs/hwui/AmbientShadow.cpp
+++ b/libs/hwui/AmbientShadow.cpp
@@ -117,10 +117,13 @@
 
         // inner ring of points
         float opacity = 1.0 / (1 + rayHeight[rayIndex] * heightFactor);
+        // NOTE: Shadow alpha values are transformed when stored in alphavertices,
+        // so that they can be consumed directly by gFS_Main_ApplyVertexAlphaShadowInterp
+        float transformedOpacity = acos(1.0f - 2.0f * opacity);
         AlphaVertex::set(&shadowVertices[rays + rayIndex],
                 intersection.x,
                 intersection.y,
-                opacity);
+                transformedOpacity);
     }
 
     if (isCasterOpaque) {
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 7123bfe..d1522b6 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1641,9 +1641,9 @@
     mCaches.disableTexCoordsVertexArray();
 }
 
-void OpenGLRenderer::setupDrawAA(bool useShadowInterp) {
-    mDescription.isAA = true;
-    mDescription.isShadowAA = useShadowInterp;
+void OpenGLRenderer::setupDrawVertexAlpha(bool useShadowAlphaInterp) {
+    mDescription.hasVertexAlpha = true;
+    mDescription.useShadowAlphaInterp = useShadowAlphaInterp;
 }
 
 void OpenGLRenderer::setupDrawColor(int color, int alpha) {
@@ -2382,7 +2382,7 @@
 
     setupDraw();
     setupDrawNoTexture();
-    if (isAA) setupDrawAA((displayFlags & kVertexBuffer_ShadowAA));
+    if (isAA) setupDrawVertexAlpha((displayFlags & kVertexBuffer_ShadowInterp));
     setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha);
     setupDrawColorFilter(getColorFilter(paint));
     setupDrawShader(getShader(paint));
@@ -3168,12 +3168,12 @@
 
     if (ambientShadowVertexBuffer && mAmbientShadowAlpha > 0) {
         paint.setARGB(casterAlpha * mAmbientShadowAlpha, 0, 0, 0);
-        drawVertexBuffer(*ambientShadowVertexBuffer, &paint, kVertexBuffer_ShadowAA);
+        drawVertexBuffer(*ambientShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
     }
 
     if (spotShadowVertexBuffer && mSpotShadowAlpha > 0) {
         paint.setARGB(casterAlpha * mSpotShadowAlpha, 0, 0, 0);
-        drawVertexBuffer(*spotShadowVertexBuffer, &paint, kVertexBuffer_ShadowAA);
+        drawVertexBuffer(*spotShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
     }
 
     return DrawGlInfo::kStatusDrew;
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 2a9badd..fc95c18 100755
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -96,7 +96,7 @@
 
 enum VertexBufferDisplayFlags {
     kVertexBuffer_Offset = 0x1,
-    kVertexBuffer_ShadowAA = 0x2,
+    kVertexBuffer_ShadowInterp = 0x2,
 };
 
 /**
@@ -847,7 +847,7 @@
     void setupDrawWithTextureAndColor(bool isAlpha8 = false);
     void setupDrawWithExternalTexture();
     void setupDrawNoTexture();
-    void setupDrawAA(bool useShadowInterp);
+    void setupDrawVertexAlpha(bool useShadowAlphaInterp);
     void setupDrawColor(int color, int alpha);
     void setupDrawColor(float r, float g, float b, float a);
     void setupDrawAlpha8Color(int color, int alpha);
diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h
index 1d95c40..56773f4 100644
--- a/libs/hwui/Program.h
+++ b/libs/hwui/Program.h
@@ -71,8 +71,8 @@
 #define PROGRAM_GRADIENT_TYPE_SHIFT 33 // 2 bits for gradient type
 #define PROGRAM_MODULATE_SHIFT 35
 
-#define PROGRAM_HAS_AA_SHIFT 36
-#define PROGRAM_HAS_SHADOW_AA_SHIFT 37
+#define PROGRAM_HAS_VERTEX_ALPHA_SHIFT 36
+#define PROGRAM_USE_SHADOW_ALPHA_INTERP_SHIFT 37
 
 #define PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT 38
 #define PROGRAM_HAS_TEXTURE_TRANSFORM_SHIFT 39
@@ -135,8 +135,8 @@
     bool hasBitmap;
     bool isBitmapNpot;
 
-    bool isAA; // drawing with a per-vertex alpha
-    bool isShadowAA; // drawing per vertex alpha with shadow interpolation
+    bool hasVertexAlpha;
+    bool useShadowAlphaInterp;
 
     bool hasGradient;
     Gradient gradientType;
@@ -176,8 +176,8 @@
 
         hasColors = false;
 
-        isAA = false;
-        isShadowAA = false;
+        hasVertexAlpha = false;
+        useShadowAlphaInterp = false;
 
         modulate = false;
 
@@ -264,8 +264,8 @@
         key |= (framebufferMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_FRAMEBUFFER_SHIFT;
         if (swapSrcDst) key |= PROGRAM_KEY_SWAP_SRC_DST;
         if (modulate) key |= programid(0x1) << PROGRAM_MODULATE_SHIFT;
-        if (isAA) key |= programid(0x1) << PROGRAM_HAS_AA_SHIFT;
-        if (isShadowAA) key |= programid(0x1) << PROGRAM_HAS_SHADOW_AA_SHIFT;
+        if (hasVertexAlpha) key |= programid(0x1) << PROGRAM_HAS_VERTEX_ALPHA_SHIFT;
+        if (useShadowAlphaInterp) key |= programid(0x1) << PROGRAM_USE_SHADOW_ALPHA_INTERP_SHIFT;
         if (hasExternalTexture) key |= programid(0x1) << PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT;
         if (hasTextureTransform) key |= programid(0x1) << PROGRAM_HAS_TEXTURE_TRANSFORM_SHIFT;
         if (hasGammaCorrection) key |= programid(0x1) << PROGRAM_HAS_GAMMA_CORRECTION;
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 2dd89b8..c802b18 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -46,7 +46,7 @@
         "attribute vec2 texCoords;\n";
 const char* gVS_Header_Attributes_Colors =
         "attribute vec4 colors;\n";
-const char* gVS_Header_Attributes_AAVertexShapeParameters =
+const char* gVS_Header_Attributes_VertexAlphaParameters =
         "attribute float vtxAlpha;\n";
 const char* gVS_Header_Uniforms_TextureTransform =
         "uniform mat4 mainTextureTransform;\n";
@@ -64,7 +64,7 @@
         "varying vec2 outTexCoords;\n";
 const char* gVS_Header_Varyings_HasColors =
         "varying vec4 outColors;\n";
-const char* gVS_Header_Varyings_IsAAVertexShape =
+const char* gVS_Header_Varyings_HasVertexAlpha =
         "varying float alpha;\n";
 const char* gVS_Header_Varyings_HasBitmap =
         "varying highp vec2 outBitmapTexCoords;\n";
@@ -122,9 +122,7 @@
         "    vec4 transformedPosition = projection * transform * position;\n"
         "    gl_Position = transformedPosition;\n";
 
-const char* gVS_Main_ShadowAAVertexShape =
-        "    alpha = pow(vtxAlpha, 0.667);\n";
-const char* gVS_Main_AAVertexShape =
+const char* gVS_Main_VertexAlpha =
         "    alpha = vtxAlpha;\n";
 
 const char* gVS_Main_HasRoundRectClip =
@@ -239,10 +237,10 @@
         "    fragColor = color;\n";
 const char* gFS_Main_ModulateColor =
         "    fragColor *= color.a;\n";
-const char* gFS_Main_AccountForAAVertexShape =
+const char* gFS_Main_ApplyVertexAlphaLinearInterp =
         "    fragColor *= alpha;\n";
-const char* gFS_Main_AccountForShadowAAVertexShape =
-        "    fragColor *= pow(alpha, 1.5);\n";
+const char* gFS_Main_ApplyVertexAlphaShadowInterp =
+        "    fragColor *= (1.0 - cos(alpha)) / 2.0;\n";
 
 const char* gFS_Main_FetchTexture[2] = {
         // Don't modulate
@@ -473,8 +471,8 @@
     if (description.hasTexture || description.hasExternalTexture) {
         shader.append(gVS_Header_Attributes_TexCoords);
     }
-    if (description.isAA) {
-        shader.append(gVS_Header_Attributes_AAVertexShapeParameters);
+    if (description.hasVertexAlpha) {
+        shader.append(gVS_Header_Attributes_VertexAlphaParameters);
     }
     if (description.hasColors) {
         shader.append(gVS_Header_Attributes_Colors);
@@ -497,8 +495,8 @@
     if (description.hasTexture || description.hasExternalTexture) {
         shader.append(gVS_Header_Varyings_HasTexture);
     }
-    if (description.isAA) {
-        shader.append(gVS_Header_Varyings_IsAAVertexShape);
+    if (description.hasVertexAlpha) {
+        shader.append(gVS_Header_Varyings_HasVertexAlpha);
     }
     if (description.hasColors) {
         shader.append(gVS_Header_Varyings_HasColors);
@@ -520,12 +518,8 @@
         } else if (description.hasTexture || description.hasExternalTexture) {
             shader.append(gVS_Main_OutTexCoords);
         }
-        if (description.isAA) {
-            if (description.isShadowAA) {
-                shader.append(gVS_Main_ShadowAAVertexShape);
-            } else {
-                shader.append(gVS_Main_AAVertexShape);
-            }
+        if (description.hasVertexAlpha) {
+            shader.append(gVS_Main_VertexAlpha);
         }
         if (description.hasColors) {
             shader.append(gVS_Main_OutColors);
@@ -575,8 +569,8 @@
     if (description.hasTexture || description.hasExternalTexture) {
         shader.append(gVS_Header_Varyings_HasTexture);
     }
-    if (description.isAA) {
-        shader.append(gVS_Header_Varyings_IsAAVertexShape);
+    if (description.hasVertexAlpha) {
+        shader.append(gVS_Header_Varyings_HasVertexAlpha);
     }
     if (description.hasColors) {
         shader.append(gVS_Header_Varyings_HasColors);
@@ -617,7 +611,7 @@
     }
 
     // Optimization for common cases
-    if (!description.isAA
+    if (!description.hasVertexAlpha
             && !blendFramebuffer
             && !description.hasColors
             && description.colorOp == ProgramDescription::kColorNone
@@ -759,11 +753,11 @@
         // Apply the color op if needed
         shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
 
-        if (description.isAA) {
-            if (description.isShadowAA) {
-                shader.append(gFS_Main_AccountForShadowAAVertexShape);
+        if (description.hasVertexAlpha) {
+            if (description.useShadowAlphaInterp) {
+                shader.append(gFS_Main_ApplyVertexAlphaShadowInterp);
             } else {
-                shader.append(gFS_Main_AccountForAAVertexShape);
+                shader.append(gFS_Main_ApplyVertexAlphaLinearInterp);
             }
         }
 
diff --git a/libs/hwui/SpotShadow.cpp b/libs/hwui/SpotShadow.cpp
index 8c3077b..d726538 100644
--- a/libs/hwui/SpotShadow.cpp
+++ b/libs/hwui/SpotShadow.cpp
@@ -754,9 +754,13 @@
     AlphaVertex* shadowVertices =
             shadowTriangleStrip.alloc<AlphaVertex>(SHADOW_VERTEX_COUNT);
 
+    // NOTE: Shadow alpha values are transformed when stored in alphavertices,
+    // so that they can be consumed directly by gFS_Main_ApplyVertexAlphaShadowInterp
+    float transformedMaxAlpha = M_PI;
+
     // Calculate the vertices (x, y, alpha) in the shadow area.
     AlphaVertex centroidXYA;
-    AlphaVertex::set(&centroidXYA, centroid.x, centroid.y, 1.0f);
+    AlphaVertex::set(&centroidXYA, centroid.x, centroid.y, transformedMaxAlpha);
     for (int rayIndex = 0; rayIndex < rays; rayIndex++) {
         float dx = cosf(step * rayIndex);
         float dy = sinf(step * rayIndex);
@@ -770,14 +774,16 @@
         // umbra ring
         float umbraDistance = umbraDistPerRay[rayIndex];
         AlphaVertex::set(&shadowVertices[rays + rayIndex],
-                dx * umbraDistance + centroid.x, dy * umbraDistance + centroid.y, 1.0f);
+                dx * umbraDistance + centroid.x,
+                dy * umbraDistance + centroid.y,
+                transformedMaxAlpha);
 
         // occluded umbra ring
         if (hasOccludedUmbraArea) {
             float occludedUmbraDistance = occludedUmbraDistPerRay[rayIndex];
             AlphaVertex::set(&shadowVertices[2 * rays + rayIndex],
                     dx * occludedUmbraDistance + centroid.x,
-                    dy * occludedUmbraDistance + centroid.y, 1.0f);
+                    dy * occludedUmbraDistance + centroid.y, transformedMaxAlpha);
         } else {
             // Put all vertices of the occluded umbra ring at the centroid.
             shadowVertices[2 * rays + rayIndex] = centroidXYA;
diff --git a/media/java/android/media/tv/TvContentRating.java b/media/java/android/media/tv/TvContentRating.java
index 25252ed..3e5ecef 100644
--- a/media/java/android/media/tv/TvContentRating.java
+++ b/media/java/android/media/tv/TvContentRating.java
@@ -1480,7 +1480,7 @@
             Arrays.sort(subRatings);
             mSubRatings = subRatings;
         }
-        mHashCode = Objects.hash(mDomain, mRating, mSubRatings);
+        mHashCode = 31 * Objects.hash(mDomain, mRating) + Arrays.hashCode(mSubRatings);
     }
 
     /**
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
index 25f3383..32f7a1e 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
@@ -36,6 +36,7 @@
 import android.provider.MediaStore;
 import android.util.Log;
 import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
 
 import com.android.keyguard.KeyguardHostView.OnDismissAction;
 
@@ -214,9 +215,9 @@
 
     private void dismissKeyguardOnNextActivity() {
         try {
-            ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
+            WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
         } catch (RemoteException e) {
-            Log.w(TAG, "can't dismiss keyguard on launch");
+            Log.w(TAG, "Error dismissing keyguard", e);
         }
     }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
index d9c5a53..e35b2b2 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
@@ -237,7 +237,7 @@
     }
 
     public void startDisappearAnimation(Runnable finishRunnable) {
-        if (!mSecurityContainer.startDisappearAnimation(finishRunnable)) {
+        if (!mSecurityContainer.startDisappearAnimation(finishRunnable) && finishRunnable != null) {
             finishRunnable.run();
         }
     }
diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
index f74843e..2e5450d 100644
--- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
@@ -61,4 +61,9 @@
      * Report when keyguard is actually gone
      */
     void keyguardGone();
+
+    /**
+     * Report when the UI is ready for dismissing the whole Keyguard.
+     */
+    void readyForKeyguardDone();
 }
diff --git a/packages/PrintSpooler/res/drawable/ic_savetopdf.xml b/packages/PrintSpooler/res/drawable/ic_savetopdf.xml
new file mode 100644
index 0000000..60ed33a
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable/ic_savetopdf.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+    android:src="@drawable/ic_menu_savetopdf"
+    android:tint="@color/promoted_action_background_color" />
diff --git a/packages/PrintSpooler/res/layout/preview_page.xml b/packages/PrintSpooler/res/layout/preview_page.xml
index 509a1d2..76dd76b 100644
--- a/packages/PrintSpooler/res/layout/preview_page.xml
+++ b/packages/PrintSpooler/res/layout/preview_page.xml
@@ -31,7 +31,7 @@
     <RelativeLayout
         android:id="@+id/page_footer"
         android:layout_width="fill_parent"
-        android:layout_height="32dip"
+        android:layout_height="@dimen/preview_page_footer_height"
         android:background="@*android:color/material_grey_500"
         android:orientation="horizontal">
 
diff --git a/packages/PrintSpooler/res/layout/print_activity.xml b/packages/PrintSpooler/res/layout/print_activity.xml
index 3905646..ee5d42a 100644
--- a/packages/PrintSpooler/res/layout/print_activity.xml
+++ b/packages/PrintSpooler/res/layout/print_activity.xml
@@ -27,7 +27,6 @@
         android:id="@+id/static_content"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:padding="16dip"
         android:elevation="@dimen/preview_controls_elevation"
         android:background="?android:attr/colorPrimary">
 
@@ -35,6 +34,7 @@
             android:id="@+id/destination_spinner"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_marginTop="4dip"
             android:dropDownWidth="wrap_content"
             android:minHeight="?android:attr/listPreferredItemHeightSmall">
         </Spinner>
@@ -56,7 +56,6 @@
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="8dip"
             android:layout_marginStart="12dip"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:labelFor="@+id/copies_count_summary"
@@ -67,7 +66,6 @@
             android:id="@+id/copies_count_summary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="8dip"
             android:layout_marginStart="16dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="?android:attr/textColorPrimary">
@@ -76,7 +74,6 @@
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="8dip"
             android:layout_marginStart="32dip"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:labelFor="@+id/paper_size_summary"
@@ -87,7 +84,6 @@
             android:id="@+id/paper_size_summary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="8dip"
             android:layout_marginStart="16dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="?android:attr/textColorPrimary">
diff --git a/packages/PrintSpooler/res/layout/print_activity_controls.xml b/packages/PrintSpooler/res/layout/print_activity_controls.xml
index ef6044a..31bda7e 100644
--- a/packages/PrintSpooler/res/layout/print_activity_controls.xml
+++ b/packages/PrintSpooler/res/layout/print_activity_controls.xml
@@ -267,8 +267,8 @@
              android:id="@+id/expand_collapse_icon"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
-             android:layout_marginTop="8dip"
-             android:layout_marginBottom="8dip"
+             android:layout_marginTop="4dip"
+             android:layout_marginBottom="4dip"
              android:layout_gravity="center"
              android:background="@drawable/ic_expand_more">
          </ImageView>
diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml
index faad527..b95703b 100644
--- a/packages/PrintSpooler/res/values/constants.xml
+++ b/packages/PrintSpooler/res/values/constants.xml
@@ -45,4 +45,7 @@
     <fraction name="page_selected_alpha">100%</fraction>
     <fraction name="page_unselected_alpha">50%</fraction>
 
+    <dimen name="preview_page_footer_height">32dip</dimen>
+    <dimen name="preview_page_min_width">130dip</dimen>
+
 </resources>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
index e976936..5bcdb9f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
@@ -96,6 +96,7 @@
     private float mUnselectedPageAlpha;
 
     private int mPreviewPageMargin;
+    private int mPreviewPageMinWidth;
     private int mPreviewListPadding;
     private int mFooterHeight;
 
@@ -141,17 +142,17 @@
         mPreviewPageMargin = mContext.getResources().getDimensionPixelSize(
                 R.dimen.preview_page_margin);
 
+        mPreviewPageMinWidth = mContext.getResources().getDimensionPixelSize(
+                R.dimen.preview_page_min_width);
+
         mPreviewListPadding = mContext.getResources().getDimensionPixelSize(
                 R.dimen.preview_list_padding);
 
         mColumnCount = mContext.getResources().getInteger(
                 R.integer.preview_page_per_row_count);
 
-        TypedValue outValue = new TypedValue();
-        mContext.getTheme().resolveAttribute(
-                com.android.internal.R.attr.listPreferredItemHeightSmall, outValue, true);
-        mFooterHeight = TypedValue.complexToDimensionPixelSize(outValue.data,
-                mContext.getResources().getDisplayMetrics());
+        mFooterHeight = mContext.getResources().getDimensionPixelSize(
+                R.dimen.preview_page_footer_height);
 
         mPreviewArea = previewArea;
 
@@ -428,8 +429,12 @@
         // Compute max page height.
         final int pageContentDesiredHeight = (int) (((float) pageContentDesiredWidth
                 / pageAspectRatio) + 0.5f);
-        final int pageContentMaxHeight = availableHeight - 2 * (mPreviewListPadding
-                + mPreviewPageMargin) - mFooterHeight;
+
+        // If the page does not fit entirely in a vertial direction,
+        // we shirk it but not less than the minimal page width.
+        final int pageContentMinHeight = (int) (mPreviewPageMinWidth / pageAspectRatio + 0.5f);
+        final int pageContentMaxHeight = Math.max(pageContentMinHeight,
+                availableHeight - 2 * (mPreviewListPadding + mPreviewPageMargin) - mFooterHeight);
 
         mPageContentHeight = Math.min(pageContentDesiredHeight, pageContentMaxHeight);
         mPageContentWidth = (int) ((mPageContentHeight * pageAspectRatio) + 0.5f);
@@ -439,10 +444,17 @@
 
         final int rowCount = mSelectedPageCount / columnCount
                 + ((mSelectedPageCount % columnCount) > 0 ? 1 : 0);
-        final int totalContentHeight = rowCount* (mPageContentHeight + mFooterHeight + 2
+        final int totalContentHeight = rowCount * (mPageContentHeight + mFooterHeight + 2
                 * mPreviewPageMargin);
-        final int verticalPadding = Math.max(mPreviewListPadding,
-                (availableHeight - totalContentHeight) / 2);
+
+        final int verticalPadding;
+        if (mPageContentHeight + mFooterHeight + mPreviewListPadding > availableHeight) {
+            verticalPadding = Math.max(mPreviewPageMargin,
+                    (availableHeight - totalContentHeight) / 2);
+        } else {
+            verticalPadding = Math.max(mPreviewListPadding,
+                    (availableHeight - totalContentHeight) / 2);
+        }
 
         mPreviewArea.setPadding(horizontalPadding, verticalPadding,
                 horizontalPadding, verticalPadding);
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index a1b1aec..6b29e5f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -1704,7 +1704,7 @@
                 if (position == 0 && getPdfPrinter() != null) {
                     PrinterHolder printerHolder = (PrinterHolder) getItem(position);
                     title = printerHolder.printer.getName();
-                    icon = getResources().getDrawable(com.android.internal.R.drawable.ic_menu_save);
+                    icon = getResources().getDrawable(R.drawable.ic_savetopdf);
                 } else if (position == 1) {
                     title = getString(R.string.all_printers);
                 }
@@ -1712,7 +1712,7 @@
                 if (position == 1 && getPdfPrinter() != null) {
                     PrinterHolder printerHolder = (PrinterHolder) getItem(position);
                     title = printerHolder.printer.getName();
-                    icon = getResources().getDrawable(com.android.internal.R.drawable.ic_menu_save);
+                    icon = getResources().getDrawable(R.drawable.ic_savetopdf);
                 } else if (position == getCount() - 1) {
                     title = getString(R.string.all_printers);
                 } else {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
index 4d2cb6c..8365373 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
@@ -94,7 +94,7 @@
         mMinMargins = minMargins;
         mContentRequested = false;
 
-        // If there is not provider we want immediately to switch to
+        // If there is no provider we want immediately to switch to
         // the empty state, so pages with no content appear blank.
         if (mProvider == null && getBackground() != mEmptyState) {
             setBackground(mEmptyState);
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
index 01f4a04..71f4aa7 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
@@ -162,7 +162,7 @@
             }
 
             cellStart = getPaddingStart();
-            cellTop += cellTop + rowHeight;
+            cellTop += rowHeight;
         }
     }
 
diff --git a/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml b/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml
new file mode 100644
index 0000000..745af33
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:attr/colorControlHighlight">
+    <item android:drawable="@android:color/transparent" />
+</ripple>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/recents_task_view.xml b/packages/SystemUI/res/layout/recents_task_view.xml
index 4a5fffe..6cfff2e3 100644
--- a/packages/SystemUI/res/layout/recents_task_view.xml
+++ b/packages/SystemUI/res/layout/recents_task_view.xml
@@ -26,8 +26,7 @@
         android:id="@+id/task_view_bar"
         android:layout_width="match_parent"
         android:layout_height="@dimen/recents_task_bar_height"
-        android:layout_gravity="top|center_horizontal"
-        android:background="@color/recents_task_bar_default_background_color">
+        android:layout_gravity="top|center_horizontal">
         <com.android.systemui.recents.views.FixedSizeImageView
             android:id="@+id/application_icon"
             android:layout_width="@dimen/recents_task_view_application_icon_size"
@@ -69,7 +68,6 @@
         android:layout_gravity="bottom|right"
         android:layout_marginRight="15dp"
         android:layout_marginBottom="15dp"
-        android:translationZ="50dp"
         android:contentDescription="@string/recents_lock_to_app_button_label"
         android:background="@drawable/recents_lock_to_task_button_bg">
         <ImageView
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 26e5ce3..28d7e29 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -147,6 +147,8 @@
     <integer name="recents_max_task_stack_view_dim">96</integer>
     <!-- The number of tasks that RecentsTaskLoader should load. -->
     <integer name="recents_max_num_tasks_to_load">50</integer>
+    <!-- The delay to enforce between each alt-tab key press. -->
+    <integer name="recents_alt_tab_key_delay">200</integer>
     <!-- Transposes the recents layout in landscape. -->
     <bool name="recents_transpose_layout_with_orientation">true</bool>
 
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 0d3a487..7301c99 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -108,49 +108,6 @@
     <style name="TextAppearance.StatusBar.Expanded.UserSwitcher.UserName" />
 
     <style name="TextAppearance" />
-    <style name="TextAppearance.QuickSettings" />
-
-    <style name="TextAppearance.QuickSettings.TileView">
-        <item name="android:textSize">12dp</item>
-        <item name="android:textStyle">normal</item>
-        <item name="android:textColor">#CCCCCC</item>
-        <item name="android:textAllCaps">true</item>
-        <item name="android:paddingStart">6dp</item>
-        <item name="android:paddingEnd">6dp</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.TileView.AllInOne" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:lines">2</item>
-        <item name="android:gravity">top</item>
-        <item name="android:paddingBottom">2dp</item>
-        <item name="android:paddingTop">16dp</item>
-        <item name="android:drawablePadding">8dp</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.Clock" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:textSize">20dp</item>
-        <item name="android:textColor">@android:color/holo_blue_light</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.Date" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:textSize">14dp</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.Alarm" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:textSize">14dp</item>
-        <item name="android:textColor">#ff3a3b39</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.CaCertWarning" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:textAllCaps">false</item>
-    </style>
-
-    <style name="TextAppearance.QuickSettings.TileView.User" parent="@style/TextAppearance.QuickSettings.TileView">
-        <item name="android:background">#CC000000</item>
-        <item name="android:padding">4dp</item>
-        <item name="android:singleLine">true</item>
-        <item name="android:fadingEdge">horizontal</item>
-    </style>
 
     <style name="TextAppearance.QS">
         <item name="android:textStyle">normal</item>
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index b280ab7..ee699d2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -208,6 +208,12 @@
             checkPermission();
             mKeyguardViewMediator.startKeyguardExitAnimation(startTime, fadeoutDuration);
         }
+
+        @Override
+        public void onActivityDrawn() {
+            checkPermission();
+            mKeyguardViewMediator.onActivityDrawn();
+        }
     };
 }
 
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 117515b..e4b395f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -133,6 +133,7 @@
     private static final int KEYGUARD_TIMEOUT = 13;
     private static final int DISMISS = 17;
     private static final int START_KEYGUARD_EXIT_ANIM = 18;
+    private static final int ON_ACTIVITY_DRAWN = 19;
 
     /**
      * The default amount of time we stay awake (used for all key input)
@@ -256,6 +257,7 @@
     private boolean mWaitingUntilKeyguardVisible = false;
     private LockPatternUtils mLockPatternUtils;
     private boolean mKeyguardDonePending = false;
+    private boolean mHideAnimationRun = false;
 
     private SoundPool mLockSounds;
     private int mLockSoundId;
@@ -287,6 +289,7 @@
             // ActivityManagerService) will not reconstruct the keyguard if it is already showing.
             synchronized (KeyguardViewMediator.this) {
                 mSwitchingUser = true;
+                mKeyguardDonePending = false;
                 resetStateLocked();
                 adjustStatusBarLocked();
                 // When we switch users we want to bring the new user to the biometric unlock even
@@ -431,12 +434,23 @@
         @Override
         public void keyguardDonePending() {
             mKeyguardDonePending = true;
+            mHideAnimationRun = true;
+            mStatusBarKeyguardViewManager.startPreHideAnimation(null /* finishRunnable */);
         }
 
         @Override
         public void keyguardGone() {
             mKeyguardDisplayManager.hide();
         }
+
+        @Override
+        public void readyForKeyguardDone() {
+            if (mKeyguardDonePending) {
+                // Somebody has called keyguardDonePending before, which means that we are
+                // authenticated
+                KeyguardViewMediator.this.keyguardDone(true /* authenticated */, true /* wakeUp */);
+            }
+        }
     };
 
     public void userActivity() {
@@ -545,6 +559,7 @@
             if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")");
 
             mKeyguardDonePending = false;
+            mHideAnimationRun = false;
 
             // Lock immediately based on setting if secure (user has a pin/pattern/password).
             // This also "locks" the device when not secure to provide easy access to the
@@ -1067,6 +1082,9 @@
                     StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj;
                     handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration);
                     break;
+                case ON_ACTIVITY_DRAWN:
+                    handleOnActivityDrawn();
+                    break;
             }
         }
     };
@@ -1181,6 +1199,7 @@
             mHiding = false;
             mShowing = true;
             mKeyguardDonePending = false;
+            mHideAnimationRun = false;
             updateActivityLockScreenState();
             adjustStatusBarLocked();
             userActivity();
@@ -1193,6 +1212,20 @@
         mKeyguardDisplayManager.show();
     }
 
+    private final Runnable mKeyguardGoingAwayRunnable = new Runnable() {
+        @Override
+        public void run() {
+            try {
+                // Don't actually hide the Keyguard at the moment, wait for window
+                // manager until it tells us it's safe to do so with
+                // startKeyguardExitAnimation.
+                mWM.keyguardGoingAway();
+            } catch (RemoteException e) {
+                Log.e(TAG, "Error while calling WindowManager", e);
+            }
+        }
+    };
+
     /**
      * Handle message sent by {@link #hideLocked()}
      * @see #HIDE
@@ -1203,19 +1236,11 @@
 
             mHiding = true;
             if (mShowing && !mOccluded) {
-                mStatusBarKeyguardViewManager.startPreHideAnimation(new Runnable() {
-                    @Override
-                    public void run() {
-                        try {
-                            // Don't actually hide the Keyguard at the moment, wait for window
-                            // manager until it tells us it's safe to do so with
-                            // startKeyguardExitAnimation.
-                            mWM.keyguardGoingAway();
-                        } catch (RemoteException e) {
-                            Log.e(TAG, "Error while calling WindowManager", e);
-                        }
-                    }
-                });
+                if (!mHideAnimationRun) {
+                    mStatusBarKeyguardViewManager.startPreHideAnimation(mKeyguardGoingAwayRunnable);
+                } else {
+                    mKeyguardGoingAwayRunnable.run();
+                }
             } else {
 
                 // Don't try to rely on WindowManager - if Keyguard wasn't showing, window
@@ -1227,6 +1252,12 @@
         }
     }
 
+    private void handleOnActivityDrawn() {
+        if (mKeyguardDonePending) {
+            mStatusBarKeyguardViewManager.onActivityDrawn();
+        }
+    }
+
     private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) {
         synchronized (KeyguardViewMediator.this) {
 
@@ -1244,6 +1275,7 @@
             mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration);
             mShowing = false;
             mKeyguardDonePending = false;
+            mHideAnimationRun = false;
             updateActivityLockScreenState();
             adjustStatusBarLocked();
         }
@@ -1357,6 +1389,9 @@
         mHandler.sendMessage(msg);
     }
 
+    public void onActivityDrawn() {
+        mHandler.sendEmptyMessage(ON_ACTIVITY_DRAWN);
+    }
     public ViewMediatorCallback getViewMediatorCallback() {
         return mViewMediatorCallback;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
index 79fadbd..8420dc0c 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
@@ -16,7 +16,6 @@
 
 package com.android.systemui.power;
 
-import android.app.ActivityManagerNative;
 import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -26,15 +25,14 @@
 import android.media.Ringtone;
 import android.media.RingtoneManager;
 import android.net.Uri;
-import android.os.RemoteException;
 import android.os.SystemClock;
-import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.Slog;
 import android.view.ContextThemeWrapper;
 import android.view.WindowManager;
 
 import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
 
 import java.io.PrintWriter;
 
@@ -43,6 +41,7 @@
     private static final boolean DEBUG = PowerUI.DEBUG;
 
     private final Context mContext;
+    private final PhoneStatusBar mPhoneStatusBar;
 
     private int mBatteryLevel;
     private int mBucket;
@@ -52,8 +51,9 @@
     private AlertDialog mInvalidChargerDialog;
     private AlertDialog mLowBatteryDialog;
 
-    public PowerDialogWarnings(Context context) {
+    public PowerDialogWarnings(Context context, PhoneStatusBar phoneStatusBar) {
         mContext = new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Light);
+        mPhoneStatusBar = phoneStatusBar;
     }
 
     @Override
@@ -121,12 +121,7 @@
                         new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
-                        try {
-                            ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
-                        } catch (RemoteException e) {
-                            // we tried
-                        }
-                        mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+                        mPhoneStatusBar.startActivity(intent, true /* dismissShade */);
                         dismissLowBatteryWarning();
                     }
                 });
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index dd923e3..d455cec 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -38,6 +38,7 @@
 import android.view.View;
 
 import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
 import com.android.systemui.statusbar.phone.SystemUIDialog;
 
 import java.io.PrintWriter;
@@ -93,10 +94,10 @@
     private boolean mInvalidCharger;
     private SystemUIDialog mSaverConfirmation;
 
-    public PowerNotificationWarnings(Context context) {
+    public PowerNotificationWarnings(Context context, PhoneStatusBar phoneStatusBar) {
         mContext = context;
         mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-        mFallbackDialogs = new PowerDialogWarnings(context);
+        mFallbackDialogs = new PowerDialogWarnings(context, phoneStatusBar);
         mReceiver.init();
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index ccef8eb..d3c7dee 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -32,6 +32,7 @@
 import android.util.Slog;
 
 import com.android.systemui.SystemUI;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -59,7 +60,7 @@
     public void start() {
         mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
         mScreenOffTime = mPowerManager.isScreenOn() ? -1 : SystemClock.elapsedRealtime();
-        mWarnings = new PowerNotificationWarnings(mContext);
+        mWarnings = new PowerNotificationWarnings(mContext, getComponent(PhoneStatusBar.class));
 
         ContentObserver obs = new ContentObserver(mHandler) {
             @Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index efb7a2c..354eb55 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -345,8 +345,8 @@
      * Creates the activity options for an app->recents transition.  If this method sets the static
      * screenshot, then we will use that for the transition.
      */
-    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask) {
-
+    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask,
+            boolean isTopTaskHome) {
         if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
             // Recycle the last screenshot
             consumeLastScreenshot();
@@ -365,7 +365,7 @@
         Bitmap firstThumbnail = mSystemServicesProxy.getTaskThumbnail(topTask.id);
         if (firstThumbnail != null) {
             // Update the destination rect
-            Rect toTaskRect = getThumbnailTransitionRect(topTask.id);
+            Rect toTaskRect = getThumbnailTransitionRect(topTask.id, isTopTaskHome);
             if (toTaskRect.width() > 0 && toTaskRect.height() > 0) {
                 // Create the new thumbnail for the animation down
                 // XXX: We should find a way to optimize this so we don't need to create a new bitmap
@@ -389,7 +389,7 @@
     }
 
     /** Returns the transition rect for the given task id. */
-    Rect getThumbnailTransitionRect(int runningTaskId) {
+    Rect getThumbnailTransitionRect(int runningTaskId, boolean isTopTaskHome) {
         // Get the stack of tasks that we are animating into
         TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy, -1);
         if (stack.getTaskCount() == 0) {
@@ -401,7 +401,8 @@
         TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
         Rect taskStackBounds = new Rect(mTaskStackBounds);
         taskStackBounds.bottom -= mSystemInsets.bottom;
-        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds, mTriggeredFromAltTab);
+        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds,
+                mTriggeredFromAltTab, isTopTaskHome);
         tsv.getScroller().setStackScrollToInitialState();
 
         // Find the running task in the TaskStack
@@ -442,7 +443,7 @@
 
         if (useThumbnailTransition) {
             // Try starting with a thumbnail transition
-            ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask);
+            ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask, isTopTaskHome);
             if (opts != null) {
                 if (sLastScreenshot != null) {
                     startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_FULL_SCREENSHOT);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 417049c..41e06de 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -61,6 +61,7 @@
 
     RecentsConfiguration mConfig;
     boolean mVisible;
+    long mLastTabKeyEventTime;
 
     // Top level views
     RecentsView mRecentsView;
@@ -512,17 +513,33 @@
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-        if (keyCode == KeyEvent.KEYCODE_TAB) {
-            // Focus the next task in the stack
-            final boolean backward = event.isShiftPressed();
-            mRecentsView.focusNextTask(!backward);
-            return true;
-        } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
-            mRecentsView.focusNextTask(true);
-            return true;
-        } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
-            mRecentsView.focusNextTask(false);
-            return true;
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_TAB: {
+                boolean hasRepKeyTimeElapsed = (System.currentTimeMillis() -
+                        mLastTabKeyEventTime) > mConfig.altTabKeyDelay;
+                if (event.getRepeatCount() <= 0 || hasRepKeyTimeElapsed) {
+                    // Focus the next task in the stack
+                    final boolean backward = event.isShiftPressed();
+                    mRecentsView.focusNextTask(!backward);
+                    mLastTabKeyEventTime = System.currentTimeMillis();
+                }
+                return true;
+            }
+            case KeyEvent.KEYCODE_DPAD_UP: {
+                mRecentsView.focusNextTask(true);
+                return true;
+            }
+            case KeyEvent.KEYCODE_DPAD_DOWN: {
+                mRecentsView.focusNextTask(false);
+                return true;
+            }
+            case KeyEvent.KEYCODE_DEL:
+            case KeyEvent.KEYCODE_FORWARD_DEL: {
+                mRecentsView.dismissFocusedTask();
+                return true;
+            }
+            default:
+                break;
         }
         // Pass through the debug trigger
         mDebugTrigger.onKeyEvent(keyCode);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 65e7076..3f5018d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -112,6 +112,9 @@
     public boolean launchedFromHome;
     public int launchedToTaskId;
 
+    /** Misc **/
+    public int altTabKeyDelay;
+
     /** Dev options and global settings */
     public boolean lockToAppEnabled;
     public boolean developerOptionsEnabled;
@@ -250,6 +253,9 @@
         // Nav bar scrim
         navBarScrimEnterDuration =
                 res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration);
+
+        // Misc
+        altTabKeyDelay = res.getInteger(R.integer.recents_alt_tab_key_delay);
     }
 
     /** Updates the system insets */
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
index bd5df28..4c6b389 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
@@ -89,6 +89,17 @@
         return Math.abs((fgL + 0.05f) / (bgL + 0.05f));
     }
 
+    /** Returns the base color overlaid with another overlay color with a specified alpha. */
+    public static int getColorWithOverlay(int baseColor, int overlayColor, float overlayAlpha) {
+        return Color.rgb(
+            (int) (overlayAlpha * Color.red(baseColor) +
+                    (1f - overlayAlpha) * Color.red(overlayColor)),
+            (int) (overlayAlpha * Color.green(baseColor) +
+                    (1f - overlayAlpha) * Color.green(overlayColor)),
+            (int) (overlayAlpha * Color.blue(baseColor) +
+                    (1f - overlayAlpha) * Color.blue(overlayColor)));
+    }
+
     /** Sets some private shadow properties. */
     public static void setShadowProperty(String property, String value)
             throws IllegalAccessException, InvocationTargetException {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index 0269141..98bf151 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -20,6 +20,7 @@
 import com.android.systemui.recents.Constants;
 import com.android.systemui.recents.RecentsConfiguration;
 import com.android.systemui.recents.misc.NamedCounter;
+import com.android.systemui.recents.misc.Utilities;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -433,10 +434,8 @@
                 float alpha = 1f;
                 for (int j = 0; j < taskCount; j++) {
                     Task t = tasksMap.get(group.mTaskKeys.get(j));
-                    t.colorPrimary = Color.rgb(
-                            (int) (alpha * Color.red(affiliationColor) + (1f - alpha) * 0xFF),
-                            (int) (alpha * Color.green(affiliationColor) + (1f - alpha) * 0xFF),
-                            (int) (alpha * Color.blue(affiliationColor) + (1f - alpha) * 0xFF));
+                    t.colorPrimary = Utilities.getColorWithOverlay(affiliationColor, Color.WHITE,
+                            alpha);
                     alpha -= alphaStep;
                 }
             }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 34e8860..07a7e74 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -316,12 +316,11 @@
     /** Notifies each task view of the user interaction. */
     public void onUserInteraction() {
         // Get the first stack view
-        TaskStackView stackView = null;
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
             if (child != mSearchBar) {
-                stackView = (TaskStackView) child;
+                TaskStackView stackView = (TaskStackView) child;
                 stackView.onUserInteraction();
             }
         }
@@ -330,18 +329,28 @@
     /** Focuses the next task in the first stack view */
     public void focusNextTask(boolean forward) {
         // Get the first stack view
-        TaskStackView stackView = null;
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
             if (child != mSearchBar) {
-                stackView = (TaskStackView) child;
+                TaskStackView stackView = (TaskStackView) child;
+                stackView.focusNextTask(forward);
                 break;
             }
         }
+    }
 
-        if (stackView != null) {
-            stackView.focusNextTask(forward);
+    /** Dismisses the focused task. */
+    public void dismissFocusedTask() {
+        // Get the first stack view
+        int childCount = getChildCount();
+        for (int i = 0; i < childCount; i++) {
+            View child = getChildAt(i);
+            if (child != mSearchBar) {
+                TaskStackView stackView = (TaskStackView) child;
+                stackView.dismissFocusedTask();
+                break;
+            }
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 46996bb..4fd9136 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -349,9 +349,10 @@
     }
 
     /** Updates the min and max virtual scroll bounds */
-    void updateMinMaxScroll(boolean boundScrollToNewMinMax, boolean launchedWithAltTab) {
+    void updateMinMaxScroll(boolean boundScrollToNewMinMax, boolean launchedWithAltTab,
+            boolean launchedFromHome) {
         // Compute the min and max scroll values
-        mLayoutAlgorithm.computeMinMaxScroll(mStack.getTasks(), launchedWithAltTab);
+        mLayoutAlgorithm.computeMinMaxScroll(mStack.getTasks(), launchedWithAltTab, launchedFromHome);
 
         // Debug logging
         if (boundScrollToNewMinMax) {
@@ -366,6 +367,9 @@
 
     /** Focuses the task at the specified index in the stack */
     void focusTask(int taskIndex, boolean scrollToNewPosition) {
+        // Return early if the task is already focused
+        if (taskIndex == mFocusedTaskIndex) return;
+
         if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
             mFocusedTaskIndex = taskIndex;
 
@@ -406,14 +410,24 @@
     void focusNextTask(boolean forward) {
         // Find the next index to focus
         int numTasks = mStack.getTaskCount();
-        if (mFocusedTaskIndex < 0) {
-            mFocusedTaskIndex = numTasks - 1;
-        }
+        if (numTasks == 0) return;
+
+        int nextFocusIndex = numTasks - 1;
         if (0 <= mFocusedTaskIndex && mFocusedTaskIndex < numTasks) {
-            mFocusedTaskIndex = Math.max(0, Math.min(numTasks - 1,
+            nextFocusIndex = Math.max(0, Math.min(numTasks - 1,
                     mFocusedTaskIndex + (forward ? -1 : 1)));
         }
-        focusTask(mFocusedTaskIndex, true);
+        focusTask(nextFocusIndex, true);
+    }
+
+    /** Dismisses the focused task. */
+    public void dismissFocusedTask() {
+        // Return early if there is no focused task index
+        if (mFocusedTaskIndex < 0) return;
+
+        Task t = mStack.getTasks().get(mFocusedTaskIndex);
+        TaskView tv = getChildViewForTask(t);
+        tv.dismissTask();
     }
 
     @Override
@@ -436,12 +450,12 @@
 
     /** Computes the stack and task rects */
     public void computeRects(int windowWidth, int windowHeight, Rect taskStackBounds,
-                             boolean launchedWithAltTab) {
+            boolean launchedWithAltTab, boolean launchedFromHome) {
         // Compute the rects in the stack algorithm
         mLayoutAlgorithm.computeRects(windowWidth, windowHeight, taskStackBounds);
 
         // Update the scroll bounds
-        updateMinMaxScroll(false, launchedWithAltTab);
+        updateMinMaxScroll(false, launchedWithAltTab, launchedFromHome);
     }
 
     /**
@@ -456,7 +470,8 @@
         // Compute our stack/task rects
         Rect taskStackBounds = new Rect(mTaskStackBounds);
         taskStackBounds.bottom -= mConfig.systemInsets.bottom;
-        computeRects(width, height, taskStackBounds, mConfig.launchedWithAltTab);
+        computeRects(width, height, taskStackBounds, mConfig.launchedWithAltTab,
+                mConfig.launchedFromHome);
 
         // If this is the first layout, then scroll to the front of the stack and synchronize the
         // stack views immediately to load all the views
@@ -546,7 +561,11 @@
 
         // When Alt-Tabbing, we scroll to and focus the previous task
         if (mConfig.launchedWithAltTab) {
-            focusTask(Math.max(0, mStack.getTaskCount() - 2), false);
+            if (mConfig.launchedFromHome) {
+                focusTask(Math.max(0, mStack.getTaskCount() - 1), false);
+            } else {
+                focusTask(Math.max(0, mStack.getTaskCount() - 2), false);
+            }
         }
     }
 
@@ -661,7 +680,7 @@
         mCb.onTaskViewDismissed(removedTask);
 
         // Update the min/max scroll and animate other task views into their new positions
-        updateMinMaxScroll(true, mConfig.launchedWithAltTab);
+        updateMinMaxScroll(true, mConfig.launchedWithAltTab, mConfig.launchedFromHome);
         requestSynchronizeStackViewsWithModel(200);
 
         // Update the new front most task
@@ -859,11 +878,23 @@
     @Override
     public void onTaskViewDismissed(TaskView tv) {
         Task task = tv.getTask();
+        int taskIndex = mStack.indexOfTask(task);
+        boolean taskWasFocused = tv.isFocusedTask();
         // Announce for accessibility
         tv.announceForAccessibility(getContext().getString(R.string.accessibility_recents_item_dismissed,
                 tv.getTask().activityLabel));
         // Remove the task from the view
         mStack.removeTask(task);
+        // If the dismissed task was focused, then we should focus the next task in front
+        if (taskWasFocused) {
+            ArrayList<Task> tasks = mStack.getTasks();
+            int nextTaskIndex = Math.min(tasks.size() - 1, taskIndex);
+            if (nextTaskIndex >= 0) {
+                Task nextTask = tasks.get(nextTaskIndex);
+                TaskView nextTv = getChildViewForTask(nextTask);
+                nextTv.setFocusedTask();
+            }
+        }
     }
 
     @Override
@@ -876,6 +907,13 @@
         requestSynchronizeStackViewsWithModel();
     }
 
+    @Override
+    public void onTaskViewFocusChanged(TaskView tv, boolean focused) {
+        if (focused) {
+            mFocusedTaskIndex = mStack.indexOfTask(tv.getTask());
+        }
+    }
+
     /**** TaskStackViewScroller.TaskStackViewScrollerCallbacks ****/
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
index 6c8de72..495d00b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
@@ -91,7 +91,8 @@
 
     /** Computes the minimum and maximum scroll progress values.  This method may be called before
      * the RecentsConfiguration is set, so we need to pass in the alt-tab state. */
-    void computeMinMaxScroll(ArrayList<Task> tasks, boolean launchedWithAltTab) {
+    void computeMinMaxScroll(ArrayList<Task> tasks, boolean launchedWithAltTab,
+            boolean launchedFromHome) {
         // Clear the progress map
         mTaskProgressMap.clear();
 
@@ -101,10 +102,16 @@
             return;
         }
 
+        // Note that we should account for the scale difference of the offsets at the screen bottom
         int taskHeight = mTaskRect.height();
         float pAtBottomOfStackRect = screenYToCurveProgress(mStackVisibleRect.bottom);
-        float pWithinAffiliateOffset = pAtBottomOfStackRect -
-                screenYToCurveProgress(mStackVisibleRect.bottom - mWithinAffiliationOffset);
+        float pWithinAffiliateTop = screenYToCurveProgress(mStackVisibleRect.bottom -
+                mWithinAffiliationOffset);
+        float scale = curveProgressToScale(pWithinAffiliateTop);
+        int scaleYOffset = (int) (((1f - scale) * taskHeight) / 2);
+        pWithinAffiliateTop = screenYToCurveProgress(mStackVisibleRect.bottom -
+                mWithinAffiliationOffset + scaleYOffset);
+        float pWithinAffiliateOffset = pAtBottomOfStackRect - pWithinAffiliateTop;
         float pBetweenAffiliateOffset = pAtBottomOfStackRect -
                 screenYToCurveProgress(mStackVisibleRect.bottom - mBetweenAffiliationOffset);
         float pTaskHeightOffset = pAtBottomOfStackRect -
@@ -133,8 +140,13 @@
         mMaxScrollP = pAtFrontMostCardTop - ((1f - pTaskHeightOffset - pNavBarOffset));
         mMinScrollP = tasks.size() == 1 ? Math.max(mMaxScrollP, 0f) : 0f;
         if (launchedWithAltTab) {
-            // Center the second most task, since that will be focused first
-            mInitialScrollP = pAtSecondFrontMostCardTop - 0.5f;
+            if (launchedFromHome) {
+                // Center the top most task, since that will be focused first
+                mInitialScrollP = pAtSecondFrontMostCardTop - 0.5f;
+            } else {
+                // Center the second top most task, since that will be focused first
+                mInitialScrollP = pAtSecondFrontMostCardTop - 0.5f;
+            }
         } else {
             mInitialScrollP = pAtFrontMostCardTop - 0.825f;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
index 0a12dab..2c0dc44 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
@@ -133,7 +133,7 @@
         stopBoundScrollAnimation();
 
         mScrollAnimator = ObjectAnimator.ofFloat(this, "stackScroll", curScroll, newScroll);
-        mScrollAnimator.setDuration(250);
+        mScrollAnimator.setDuration(200);
         // We would have to project the difference into the screen coords, and then use that as the
         // duration
 //        mScrollAnimator.setDuration(Utilities.calculateTranslationAnimationDuration(newScroll -
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 3b9bcc4..236229e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -48,6 +48,7 @@
         public void onTaskViewDismissed(TaskView tv);
         public void onTaskViewClipStateChanged(TaskView tv);
         public void onTaskViewFullScreenTransitionCompleted();
+        public void onTaskViewFocusChanged(TaskView tv, boolean focused);
     }
 
     RecentsConfiguration mConfig;
@@ -62,13 +63,14 @@
     Task mTask;
     boolean mTaskDataLoaded;
     boolean mIsFocused;
+    boolean mFocusAnimationsEnabled;
     boolean mIsFullScreenView;
     boolean mClipViewInStack;
     AnimateableViewBounds mViewBounds;
     Paint mLayerPaint = new Paint();
 
     TaskViewThumbnail mThumbnailView;
-    TaskViewHeader mBarView;
+    TaskViewHeader mHeaderView;
     TaskViewFooter mFooterView;
     View mActionButtonView;
     TaskViewCallbacks mCb;
@@ -124,7 +126,7 @@
     @Override
     protected void onFinishInflate() {
         // Bind the views
-        mBarView = (TaskViewHeader) findViewById(R.id.task_view_bar);
+        mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar);
         mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
         mActionButtonView = findViewById(R.id.lock_to_app_fab);
         if (mFooterView != null) {
@@ -138,7 +140,7 @@
         int height = MeasureSpec.getSize(heightMeasureSpec);
 
         // Measure the bar view, thumbnail, and footer
-        mBarView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+        mHeaderView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
                 MeasureSpec.makeMeasureSpec(mConfig.taskBarHeight, MeasureSpec.EXACTLY));
         if (mFooterView != null) {
             mFooterView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
@@ -218,11 +220,11 @@
 
     /** Prepares this task view for the enter-recents animations.  This is called earlier in the
      * first layout because the actual animation into recents may take a long time. */
-    public void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask,
+    void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask,
                                              boolean occludesLaunchTarget, int offscreenY) {
         if (mConfig.launchedFromAppWithScreenshot) {
             if (isTaskViewLaunchTargetTask) {
-                mBarView.prepareEnterRecentsAnimation();
+                mHeaderView.prepareEnterRecentsAnimation();
                 // Hide the footer during the transition in, and animate it out afterwards?
                 if (mFooterView != null) {
                     mFooterView.animateFooterVisibility(false, 0);
@@ -234,7 +236,7 @@
         } else if (mConfig.launchedFromAppWithThumbnail) {
             if (isTaskViewLaunchTargetTask) {
                 // Hide the front most task bar view so we can animate it in
-                mBarView.prepareEnterRecentsAnimation();
+                mHeaderView.prepareEnterRecentsAnimation();
                 // Hide the action button if it exists
                 mActionButtonView.setAlpha(0f);
                 // Set the dim to 0 so we can animate it in
@@ -256,8 +258,9 @@
     }
 
     /** Animates this task view as it enters recents */
-    public void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) {
+    void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) {
         final TaskViewTransform transform = ctx.currentTaskTransform;
+        int startDelay = 0;
 
         if (mConfig.launchedFromAppWithScreenshot) {
             if (mTask.isLaunchTarget) {
@@ -269,6 +272,7 @@
                 float scaledWindowInsetTop = (int) (taskScale * windowInsetTop);
                 float scaledTranslationY = taskRect.top + transform.translationY -
                         (scaledWindowInsetTop + scaledYOffset);
+                startDelay = mConfig.taskViewEnterFromHomeDelay;
 
                 // Animate the top clip
                 mViewBounds.animateClipTop(windowInsetTop, duration,
@@ -276,7 +280,7 @@
                     @Override
                     public void onAnimationUpdate(ValueAnimator animation) {
                         int y = (Integer) animation.getAnimatedValue();
-                        mBarView.setTranslationY(y);
+                        mHeaderView.setTranslationY(y);
                     }
                 });
                 // Animate the bottom or right clip
@@ -287,7 +291,7 @@
                     mViewBounds.animateClipBottom(getMeasuredHeight() - (windowInsetTop + size), duration);
                 }
                 // Animate the task bar of the first task view
-                mBarView.startEnterRecentsAnimation(0, null);
+                mHeaderView.startEnterRecentsAnimation(0, null);
                 animate()
                         .scaleX(taskScale)
                         .scaleY(taskScale)
@@ -304,9 +308,9 @@
                                 mViewBounds.setClipBottom(0);
                                 mViewBounds.setClipRight(0);
                                 // Reset the bar translation
-                                mBarView.setTranslationY(0);
+                                mHeaderView.setTranslationY(0);
                                 // Enable the thumbnail clip
-                                mThumbnailView.enableTaskBarClip(mBarView);
+                                mThumbnailView.enableTaskBarClip(mHeaderView);
                                 // Animate the footer into view (if it is the front most task)
                                 animateFooterVisibility(true, mConfig.taskBarEnterAnimDuration);
 
@@ -324,7 +328,7 @@
                         .start();
             } else {
                 // Otherwise, just enable the thumbnail clip
-                mThumbnailView.enableTaskBarClip(mBarView);
+                mThumbnailView.enableTaskBarClip(mHeaderView);
 
                 // Animate the footer into view
                 animateFooterVisibility(true, 0);
@@ -334,8 +338,8 @@
         } else if (mConfig.launchedFromAppWithThumbnail) {
             if (mTask.isLaunchTarget) {
                 // Animate the task bar of the first task view
-                mBarView.startEnterRecentsAnimation(mConfig.taskBarEnterAnimDelay,
-                        mThumbnailView.enableTaskBarClipAsRunnable(mBarView));
+                mHeaderView.startEnterRecentsAnimation(mConfig.taskBarEnterAnimDelay,
+                        mThumbnailView.enableTaskBarClipAsRunnable(mHeaderView));
 
                 // Animate the dim into view as well
                 ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", getDimFromTaskProgress());
@@ -364,7 +368,7 @@
                         .start();
             } else {
                 // Enable the task bar clip
-                mThumbnailView.enableTaskBarClip(mBarView);
+                mThumbnailView.enableTaskBarClip(mHeaderView);
                 // Animate the task up if it was occluding the launch target
                 if (ctx.currentTaskOccludesLaunchTarget) {
                     setTranslationY(transform.translationY + mConfig.taskViewAffiliateGroupEnterOffsetPx);
@@ -378,7 +382,7 @@
                             .withEndAction(new Runnable() {
                                 @Override
                                 public void run() {
-                                    mThumbnailView.enableTaskBarClip(mBarView);
+                                    mThumbnailView.enableTaskBarClip(mHeaderView);
                                     // Decrement the post animation trigger
                                     ctx.postAnimationTrigger.decrement();
                                 }
@@ -387,6 +391,7 @@
                     ctx.postAnimationTrigger.increment();
                 }
             }
+            startDelay = mConfig.taskBarEnterAnimDelay;
 
         } else if (mConfig.launchedFromHome) {
             // Animate the tasks up
@@ -407,7 +412,7 @@
                     .withEndAction(new Runnable() {
                         @Override
                         public void run() {
-                            mThumbnailView.enableTaskBarClip(mBarView);
+                            mThumbnailView.enableTaskBarClip(mHeaderView);
                             // Decrement the post animation trigger
                             ctx.postAnimationTrigger.decrement();
                         }
@@ -417,18 +422,28 @@
 
             // Animate the footer into view
             animateFooterVisibility(true, mConfig.taskViewEnterFromHomeDuration);
+            startDelay = delay;
 
         } else {
             // Otherwise, just enable the thumbnail clip
-            mThumbnailView.enableTaskBarClip(mBarView);
+            mThumbnailView.enableTaskBarClip(mHeaderView);
 
             // Animate the footer into view
             animateFooterVisibility(true, 0);
         }
+
+        // Enable the focus animations from this point onwards so that they aren't affected by the
+        // window transitions
+        postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                enableFocusAnimations();
+            }
+        }, (startDelay / 2));
     }
 
     /** Animates this task view as it leaves recents by pressing home. */
-    public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
+    void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
         animate()
                 .translationY(ctx.offscreenTranslationY)
                 .setStartDelay(0)
@@ -441,11 +456,11 @@
     }
 
     /** Animates this task view as it exits recents */
-    public void startLaunchTaskAnimation(final Runnable r, boolean isLaunchingTask,
-                                         boolean occludesLaunchTarget) {
+    void startLaunchTaskAnimation(final Runnable r, boolean isLaunchingTask,
+            boolean occludesLaunchTarget) {
         if (isLaunchingTask) {
             // Disable the thumbnail clip and animate the bar out
-            mBarView.startLaunchTaskAnimation(mThumbnailView.disableTaskBarClipAsRunnable(), r);
+            mHeaderView.startLaunchTaskAnimation(mThumbnailView.disableTaskBarClipAsRunnable(), r);
 
             // Animate the dim
             if (mDim > 0) {
@@ -464,7 +479,7 @@
                     .start();
         } else {
             // Hide the dismiss button
-            mBarView.startLaunchTaskDismissAnimation();
+            mHeaderView.startLaunchTaskDismissAnimation();
             // If this is another view in the task grouping and is in front of the launch task,
             // animate it away first
             if (occludesLaunchTarget) {
@@ -480,7 +495,7 @@
     }
 
     /** Animates the deletion of this task view */
-    public void startDeleteTaskAnimation(final Runnable r) {
+    void startDeleteTaskAnimation(final Runnable r) {
         // Disabling clipping with the stack while the view is animating away
         setClipViewInStack(false);
 
@@ -508,19 +523,33 @@
     }
 
     /** Animates this task view if the user does not interact with the stack after a certain time. */
-    public void startNoUserInteractionAnimation() {
-        mBarView.startNoUserInteractionAnimation();
+    void startNoUserInteractionAnimation() {
+        mHeaderView.startNoUserInteractionAnimation();
     }
 
     /** Mark this task view that the user does has not interacted with the stack after a certain time. */
-    public void setNoUserInteractionState() {
-        mBarView.setNoUserInteractionState();
+    void setNoUserInteractionState() {
+        mHeaderView.setNoUserInteractionState();
+    }
+
+    /** Dismisses this task. */
+    void dismissTask() {
+        // Animate out the view and call the callback
+        final TaskView tv = this;
+        startDeleteTaskAnimation(new Runnable() {
+            @Override
+            public void run() {
+                mCb.onTaskViewDismissed(tv);
+            }
+        });
+        // Hide the footer
+        animateFooterVisibility(false, mConfig.taskViewRemoveAnimDuration);
     }
 
     /** Sets whether this task view is full screen or not. */
     void setIsFullScreen(boolean isFullscreen) {
         mIsFullScreenView = isFullscreen;
-        mBarView.setIsFullscreen(isFullscreen);
+        mHeaderView.setIsFullscreen(isFullscreen);
         if (isFullscreen) {
             // If we are full screen, then disable the bottom outline clip for the footer
             mViewBounds.setOutlineClipBottom(0);
@@ -614,6 +643,12 @@
      */
     public void setFocusedTask() {
         mIsFocused = true;
+        if (mFocusAnimationsEnabled) {
+            // Focus the header bar
+            mHeaderView.onTaskViewFocusChanged(true);
+        }
+        // Call the callback
+        mCb.onTaskViewFocusChanged(this, true);
         // Workaround, we don't always want it focusable in touch mode, but we want the first task
         // to be focused after the enter-recents animation, which can be triggered from either touch
         // or keyboard
@@ -631,6 +666,12 @@
         super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
         if (!gainFocus) {
             mIsFocused = false;
+            if (mFocusAnimationsEnabled) {
+                // Un-focus the header bar
+                mHeaderView.onTaskViewFocusChanged(false);
+            }
+            // Call the callback
+            mCb.onTaskViewFocusChanged(this, false);
             invalidate();
         }
     }
@@ -642,6 +683,16 @@
         return mIsFocused || isFocused();
     }
 
+    /** Enables all focus animations. */
+    void enableFocusAnimations() {
+        boolean wasFocusAnimationsEnabled = mFocusAnimationsEnabled;
+        mFocusAnimationsEnabled = true;
+        if (mIsFocused && !wasFocusAnimationsEnabled) {
+            // Re-notify the header if we were focused and animations were not previously enabled
+            mHeaderView.onTaskViewFocusChanged(true);
+        }
+    }
+
     /**** TaskCallbacks Implementation ****/
 
     /** Binds this task view to the task */
@@ -662,24 +713,24 @@
 
     @Override
     public void onTaskDataLoaded() {
-        if (mThumbnailView != null && mBarView != null) {
+        if (mThumbnailView != null && mHeaderView != null) {
             // Bind each of the views to the new task data
             if (mIsFullScreenView) {
                 mThumbnailView.bindToScreenshot(AlternateRecentsComponent.getLastScreenshot());
             } else {
                 mThumbnailView.rebindToTask(mTask);
             }
-            mBarView.rebindToTask(mTask);
+            mHeaderView.rebindToTask(mTask);
             // Rebind any listeners
-            mBarView.mApplicationIcon.setOnClickListener(this);
-            mBarView.mDismissButton.setOnClickListener(this);
+            mHeaderView.mApplicationIcon.setOnClickListener(this);
+            mHeaderView.mDismissButton.setOnClickListener(this);
             if (mFooterView != null) {
                 mFooterView.setOnClickListener(this);
             }
             mActionButtonView.setOnClickListener(this);
             if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
                 if (mConfig.developerOptionsEnabled) {
-                    mBarView.mApplicationIcon.setOnLongClickListener(this);
+                    mHeaderView.mApplicationIcon.setOnLongClickListener(this);
                 }
             }
         }
@@ -688,20 +739,20 @@
 
     @Override
     public void onTaskDataUnloaded() {
-        if (mThumbnailView != null && mBarView != null) {
+        if (mThumbnailView != null && mHeaderView != null) {
             // Unbind each of the views from the task data and remove the task callback
             mTask.setCallbacks(null);
             mThumbnailView.unbindFromTask();
-            mBarView.unbindFromTask();
+            mHeaderView.unbindFromTask();
             // Unbind any listeners
-            mBarView.mApplicationIcon.setOnClickListener(null);
-            mBarView.mDismissButton.setOnClickListener(null);
+            mHeaderView.mApplicationIcon.setOnClickListener(null);
+            mHeaderView.mDismissButton.setOnClickListener(null);
             if (mFooterView != null) {
                 mFooterView.setOnClickListener(null);
             }
             mActionButtonView.setOnClickListener(null);
             if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
-                mBarView.mApplicationIcon.setOnLongClickListener(null);
+                mHeaderView.mApplicationIcon.setOnLongClickListener(null);
             }
         }
         mTaskDataLoaded = false;
@@ -734,18 +785,10 @@
         postDelayed(new Runnable() {
             @Override
             public void run() {
-                if (Constants.DebugFlags.App.EnableTaskFiltering && v == mBarView.mApplicationIcon) {
+                if (Constants.DebugFlags.App.EnableTaskFiltering && v == mHeaderView.mApplicationIcon) {
                     mCb.onTaskViewAppIconClicked(tv);
-                } else if (v == mBarView.mDismissButton) {
-                    // Animate out the view and call the callback
-                    startDeleteTaskAnimation(new Runnable() {
-                        @Override
-                        public void run() {
-                            mCb.onTaskViewDismissed(tv);
-                        }
-                    });
-                    // Hide the footer
-                    tv.animateFooterVisibility(false, mConfig.taskViewRemoveAnimDuration);
+                } else if (v == mHeaderView.mDismissButton) {
+                    dismissTask();
                 } else {
                     mCb.onTaskViewClicked(tv, tv.getTask(),
                             (v == mFooterView || v == mActionButtonView));
@@ -758,7 +801,7 @@
 
     @Override
     public boolean onLongClick(View v) {
-        if (v == mBarView.mApplicationIcon) {
+        if (v == mHeaderView.mApplicationIcon) {
             mCb.onTaskViewAppInfoClicked(this);
             return true;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 03fc16e..4b09549 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -16,9 +16,16 @@
 
 package com.android.systemui.recents.views;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ArgbEvaluator;
+import android.animation.ValueAnimator;
 import android.content.Context;
+import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Outline;
 import android.graphics.Paint;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffXfermode;
@@ -28,12 +35,14 @@
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewOutlineProvider;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.TextView;
 import com.android.systemui.R;
 import com.android.systemui.recents.Constants;
 import com.android.systemui.recents.RecentsConfiguration;
+import com.android.systemui.recents.misc.Utilities;
 import com.android.systemui.recents.model.Task;
 
 
@@ -46,10 +55,15 @@
     ImageView mApplicationIcon;
     TextView mActivityDescription;
 
+    RippleDrawable mBackground;
+    ColorDrawable mBackgroundColor;
     Drawable mLightDismissDrawable;
     Drawable mDarkDismissDrawable;
+    ValueAnimator mBackgroundColorAnimator;
 
     boolean mIsFullscreen;
+    boolean mCurrentPrimaryColorIsDark;
+    int mCurrentPrimaryColor;
 
     static Paint sHighlightPaint;
 
@@ -69,6 +83,13 @@
         super(context, attrs, defStyleAttr, defStyleRes);
         mConfig = RecentsConfiguration.getInstance();
         setWillNotDraw(false);
+        setClipToOutline(true);
+        setOutlineProvider(new ViewOutlineProvider() {
+            @Override
+            public void getOutline(View view, Outline outline) {
+                outline.setRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
+            }
+        });
 
         // Load the dismiss resources
         Resources res = context.getResources();
@@ -107,6 +128,15 @@
                 mApplicationIcon.setBackground(null);
             }
         }
+
+        mBackgroundColor = new ColorDrawable(0);
+        // Copy the ripple drawable since we are going to be manipulating it
+        mBackground = (RippleDrawable)
+                getResources().getDrawable(R.drawable.recents_task_view_header_bg);
+        mBackground = (RippleDrawable) mBackground.mutate().getConstantState().newDrawable();
+        mBackground.setColor(ColorStateList.valueOf(0));
+        mBackground.setDrawableByLayerId(mBackground.getId(0), mBackgroundColor);
+        setBackground(mBackground);
     }
 
     @Override
@@ -130,6 +160,12 @@
         return false;
     }
 
+    /** Returns the secondary color for a primary color. */
+    int getSecondaryColor(int primaryColor, boolean useLightOverlayColor) {
+        int overlayColor = useLightOverlayColor ? Color.WHITE : Color.BLACK;
+        return Utilities.getColorWithOverlay(primaryColor, overlayColor, 0.8f);
+    }
+
     /** Binds the bar view to the task */
     void rebindToTask(Task t) {
         // If an activity icon is defined, then we use that as the primary icon to show in the bar,
@@ -147,8 +183,10 @@
         int existingBgColor = (getBackground() instanceof ColorDrawable) ?
                 ((ColorDrawable) getBackground()).getColor() : 0;
         if (existingBgColor != t.colorPrimary) {
-            setBackgroundColor(t.colorPrimary);
+            mBackgroundColor.setColor(t.colorPrimary);
         }
+        mCurrentPrimaryColor = t.colorPrimary;
+        mCurrentPrimaryColorIsDark = t.useLightOnPrimaryColor;
         mActivityDescription.setTextColor(t.useLightOnPrimaryColor ?
                 mConfig.taskBarViewLightTextColor : mConfig.taskBarViewDarkTextColor);
         mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ?
@@ -165,12 +203,12 @@
 
     /** Prepares this task view for the enter-recents animations.  This is called earlier in the
      * first layout because the actual animation into recents may take a long time. */
-    public void prepareEnterRecentsAnimation() {
+    void prepareEnterRecentsAnimation() {
         setVisibility(View.INVISIBLE);
     }
 
     /** Animates this task bar as it enters recents */
-    public void startEnterRecentsAnimation(int delay, Runnable postAnimRunnable) {
+    void startEnterRecentsAnimation(int delay, Runnable postAnimRunnable) {
         // Animate the task bar of the first task view
         setVisibility(View.VISIBLE);
         setTranslationY(-getMeasuredHeight());
@@ -184,7 +222,7 @@
     }
 
     /** Animates this task bar as it exits recents */
-    public void startLaunchTaskAnimation(Runnable preAnimRunnable, final Runnable postAnimRunnable) {
+    void startLaunchTaskAnimation(Runnable preAnimRunnable, final Runnable postAnimRunnable) {
         // Animate the task bar out of the first task view
         animate()
                 .translationY(-getMeasuredHeight())
@@ -202,7 +240,7 @@
     }
 
     /** Animates this task bar dismiss button when launching a task. */
-    public void startLaunchTaskDismissAnimation() {
+    void startLaunchTaskDismissAnimation() {
         if (mDismissButton.getVisibility() == View.VISIBLE) {
             mDismissButton.animate().cancel();
             mDismissButton.animate()
@@ -216,7 +254,7 @@
     }
 
     /** Animates this task bar if the user does not interact with the stack after a certain time. */
-    public void startNoUserInteractionAnimation() {
+    void startNoUserInteractionAnimation() {
         mDismissButton.setVisibility(View.VISIBLE);
         mDismissButton.setAlpha(0f);
         mDismissButton.animate()
@@ -229,11 +267,78 @@
     }
 
     /** Mark this task view that the user does has not interacted with the stack after a certain time. */
-    public void setNoUserInteractionState() {
+    void setNoUserInteractionState() {
         if (mDismissButton.getVisibility() != View.VISIBLE) {
             mDismissButton.animate().cancel();
             mDismissButton.setVisibility(View.VISIBLE);
             mDismissButton.setAlpha(1f);
         }
     }
+
+    /** Notifies the associated TaskView has been focused. */
+    void onTaskViewFocusChanged(boolean focused) {
+        boolean isRunning = false;
+        if (mBackgroundColorAnimator != null) {
+            isRunning = mBackgroundColorAnimator.isRunning();
+            mBackgroundColorAnimator.removeAllUpdateListeners();
+            mBackgroundColorAnimator.cancel();
+        }
+        if (focused) {
+            int secondaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
+            int[][] states = new int[][] {
+                    new int[] { android.R.attr.state_enabled },
+                    new int[] { android.R.attr.state_pressed }
+            };
+            int[] newStates = new int[]{
+                    android.R.attr.state_enabled,
+                    android.R.attr.state_pressed
+            };
+            int[] colors = new int[] {
+                    secondaryColor,
+                    secondaryColor
+            };
+            mBackground.setColor(new ColorStateList(states, colors));
+            mBackground.setState(newStates);
+            // Pulse the background color
+            int currentColor = mBackgroundColor.getColor();
+            int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
+            mBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), lightPrimaryColor,
+                    currentColor);
+            mBackgroundColorAnimator.addListener(new AnimatorListenerAdapter() {
+                @Override
+                public void onAnimationStart(Animator animation) {
+                    mBackground.setState(new int[] {});
+                }
+            });
+            mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    mBackgroundColor.setColor((Integer) animation.getAnimatedValue());
+                }
+            });
+            mBackgroundColorAnimator.setRepeatCount(ValueAnimator.INFINITE);
+            mBackgroundColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
+            mBackgroundColorAnimator.setStartDelay(750);
+            mBackgroundColorAnimator.setDuration(750);
+            mBackgroundColorAnimator.start();
+        } else {
+            if (isRunning) {
+                // Restore the background color
+                int currentColor = mBackgroundColor.getColor();
+                mBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
+                        mCurrentPrimaryColor);
+                mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                    @Override
+                    public void onAnimationUpdate(ValueAnimator animation) {
+                        mBackgroundColor.setColor((Integer) animation.getAnimatedValue());
+                    }
+                });
+                mBackgroundColorAnimator.setRepeatCount(0);
+                mBackgroundColorAnimator.setDuration(150);
+                mBackgroundColorAnimator.start();
+            } else {
+                mBackground.setState(new int[] {});
+            }
+        }
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index c23a4cd..f4857eb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -42,6 +42,7 @@
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
+import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Handler;
 import android.os.IBinder;
@@ -89,6 +90,7 @@
 import com.android.systemui.SystemUI;
 import com.android.systemui.statusbar.NotificationData.Entry;
 import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
+import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
 import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
 import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
 
@@ -130,9 +132,6 @@
     public static final int EXPANDED_LEAVE_ALONE = -10000;
     public static final int EXPANDED_FULL_OPEN = -10001;
 
-    /** If true, delays dismissing the Keyguard until the ActivityManager calls back. */
-    protected static final boolean DELAY_DISMISS_TO_ACTIVITY_LAUNCH = false;
-
     protected CommandQueue mCommandQueue;
     protected IStatusBarService mBarService;
     protected H mHandler = createHandler();
@@ -156,6 +155,8 @@
 
     protected int mLayoutDirection = -1; // invalid
     private Locale mLocale;
+    private float mFontScale;
+
     protected boolean mUseHeadsUp = false;
     protected boolean mHeadsUpTicker = false;
     protected boolean mDisableNotificationAlerts = false;
@@ -163,6 +164,7 @@
     protected DevicePolicyManager mDevicePolicyManager;
     protected IDreamManager mDreamManager;
     PowerManager mPowerManager;
+    protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
     protected int mRowMinHeight;
     protected int mRowMaxHeight;
 
@@ -252,27 +254,33 @@
             }
             final boolean isActivity = pendingIntent.isActivity();
             if (isActivity) {
+                final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
                 dismissKeyguardThenExecute(new OnDismissAction() {
                     @Override
                     public boolean onDismiss() {
-                        try {
-                            // The intent we are sending is for the application, which
-                            // won't have permission to immediately start an activity after
-                            // the user switches to home.  We know it is safe to do at this
-                            // point, so make sure new activity switches are now allowed.
-                            ActivityManagerNative.getDefault().resumeAppSwitches();
-                        } catch (RemoteException e) {
+                        if (keyguardShowing) {
+                            try {
+                                ActivityManagerNative.getDefault()
+                                        .keyguardWaitingForActivityDrawn();
+                                // The intent we are sending is for the application, which
+                                // won't have permission to immediately start an activity after
+                                // the user switches to home.  We know it is safe to do at this
+                                // point, so make sure new activity switches are now allowed.
+                                ActivityManagerNative.getDefault().resumeAppSwitches();
+                            } catch (RemoteException e) {
+                            }
                         }
 
                         boolean handled = superOnClickHandler(view, pendingIntent, fillInIntent);
+                        overrideActivityPendingAppTransition(keyguardShowing);
 
                         // close the shade if it was open
                         if (handled) {
-                            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+                            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                             visibilityChanged(false);
                         }
                         // Wait for activity start.
-                        return handled && DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+                        return handled;
                     }
                 });
                 return true;
@@ -419,8 +427,10 @@
         mRecents = getComponent(RecentsComponent.class);
         mRecents.setCallback(this);
 
-        mLocale = mContext.getResources().getConfiguration().locale;
+        final Configuration currentConfig = mContext.getResources().getConfiguration();
+        mLocale = currentConfig.locale;
         mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
+        mFontScale = currentConfig.fontScale;
 
         mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
 
@@ -527,7 +537,9 @@
     protected void onConfigurationChanged(Configuration newConfig) {
         final Locale locale = mContext.getResources().getConfiguration().locale;
         final int ld = TextUtils.getLayoutDirectionFromLocale(locale);
-        if (! locale.equals(mLocale) || ld != mLayoutDirection) {
+        final float fontScale = newConfig.fontScale;
+
+        if (! locale.equals(mLocale) || ld != mLayoutDirection || fontScale != mFontScale) {
             if (DEBUG) {
                 Log.v(TAG, String.format(
                         "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection,
@@ -1064,7 +1076,7 @@
                             startAppNotificationSettingsActivity(pkg, appUidF);
                             animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
                             visibilityChanged(false);
-                            return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+                            return true;
                         }
                     });
                 }
@@ -1254,54 +1266,74 @@
         }
 
         public void onClick(final View v) {
+            final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
             dismissKeyguardThenExecute(new OnDismissAction() {
                 public boolean onDismiss() {
-                    try {
-                        // The intent we are sending is for the application, which
-                        // won't have permission to immediately start an activity after
-                        // the user switches to home.  We know it is safe to do at this
-                        // point, so make sure new activity switches are now allowed.
-                        ActivityManagerNative.getDefault().resumeAppSwitches();
-                    } catch (RemoteException e) {
+                    if (mIsHeadsUp) {
+                        mHeadsUpNotificationView.clear();
                     }
+                    AsyncTask.execute(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (keyguardShowing) {
+                                try {
+                                    ActivityManagerNative.getDefault()
+                                            .keyguardWaitingForActivityDrawn();
+                                    // The intent we are sending is for the application, which
+                                    // won't have permission to immediately start an activity after
+                                    // the user switches to home.  We know it is safe to do at this
+                                    // point, so make sure new activity switches are now allowed.
+                                    ActivityManagerNative.getDefault().resumeAppSwitches();
+                                } catch (RemoteException e) {
+                                }
+                            }
 
-                    boolean sent = false;
-                    if (mIntent != null) {
-                        int[] pos = new int[2];
-                        v.getLocationOnScreen(pos);
-                        Intent overlay = new Intent();
-                        overlay.setSourceBounds(new Rect(pos[0], pos[1],
-                                pos[0] + v.getWidth(), pos[1] + v.getHeight()));
-                        try {
-                            mIntent.send(mContext, 0, overlay);
-                            sent = true;
-                        } catch (PendingIntent.CanceledException e) {
-                            // the stack trace isn't very helpful here.
-                            // Just log the exception message.
-                            Log.w(TAG, "Sending contentIntent failed: " + e);
-                        }
-                    }
+                            if (mIntent != null) {
+                                try {
+                                    mIntent.send();
+                                } catch (PendingIntent.CanceledException e) {
+                                    // the stack trace isn't very helpful here.
+                                    // Just log the exception message.
+                                    Log.w(TAG, "Sending contentIntent failed: " + e);
 
-                    try {
-                        if (mIsHeadsUp) {
-                            mHeadsUpNotificationView.clear();
+                                    // TODO: Dismiss Keyguard.
+                                }
+                                if (mIntent.isActivity()) {
+                                    overrideActivityPendingAppTransition(keyguardShowing);
+                                }
+                            }
+
+                            try {
+                                mBarService.onNotificationClick(mNotificationKey);
+                            } catch (RemoteException ex) {
+                                // system process is dead if we're here.
+                            }
                         }
-                        mBarService.onNotificationClick(mNotificationKey);
-                    } catch (RemoteException ex) {
-                        // system process is dead if we're here.
-                    }
+                    });
 
                     // close the shade if it was open
-                    animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+                    animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                     visibilityChanged(false);
 
-                    boolean waitForActivityLaunch = sent && mIntent.isActivity();
-                    return waitForActivityLaunch && DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+                    return mIntent != null && mIntent.isActivity();
                 }
             });
         }
     }
 
+    public void animateCollapsePanels(int flags, boolean force) {
+    }
+
+    public void overrideActivityPendingAppTransition(boolean keyguardShowing) {
+        if (keyguardShowing) {
+            try {
+                mWindowManagerService.overridePendingAppTransition(null, 0, 0, null);
+            } catch (RemoteException e) {
+                Log.w(TAG, "Error overriding app transition: " + e);
+            }
+        }
+    }
+
     /**
      * The LEDs are turned o)ff when the notification panel is shown, even just a little bit.
      * This was added last-minute and is inconsistent with the way the rest of the notifications
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index a275572..43b7707 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -152,6 +152,11 @@
         logExpansionEvent(true, wasExpanded);
     }
 
+    public void resetUserExpansion() {
+        mHasUserChangedExpansion = false;
+        mUserExpanded = false;
+    }
+
     public boolean isUserLocked() {
         return mUserLocked;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
index 5bc7e5a..23810f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
@@ -24,5 +24,5 @@
  * Keyguard.
  */
 public interface ActivityStarter {
-    public void startActivity(Intent intent);
+    public void startActivity(Intent intent, boolean dismissShade);
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index e11f20f..6a800fd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -221,12 +221,12 @@
                 !mPreviewInflater.wouldLaunchResolverActivity(intent)) {
             mContext.startActivityAsUser(intent, UserHandle.CURRENT);
         } else {
-            mActivityStarter.startActivity(intent);
+            mActivityStarter.startActivity(intent, false /* dismissShade */);
         }
     }
 
     public void launchPhone() {
-        mActivityStarter.startActivity(PHONE_INTENT);
+        mActivityStarter.startActivity(PHONE_INTENT, false /* dismissShade */);
     }
 
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index db42b9d..fc737bee 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -98,7 +98,7 @@
     public void startPreHideAnimation(Runnable runnable) {
         if (mKeyguardView != null) {
             mKeyguardView.startDisappearAnimation(runnable);
-        } else {
+        } else if (runnable != null) {
             runnable.run();
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index acdc6bc..bac46be 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -414,12 +414,12 @@
     }
 
     @Override
-    public void fling(float vel, boolean always) {
+    public void fling(float vel, boolean expand) {
         GestureRecorder gr = ((PhoneStatusBarView) mBar).mBar.getGestureRecorder();
         if (gr != null) {
             gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel);
         }
-        super.fling(vel, always);
+        super.fling(vel, expand);
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index 59f94f2..f74d2f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -140,7 +140,7 @@
         mPanelHolder.setSelectedPanel(mTouchingPanel);
         for (PanelView pv : mPanels) {
             if (pv != panel) {
-                pv.collapse();
+                pv.collapse(false /* delayed */);
             }
         }
     }
@@ -191,7 +191,7 @@
         boolean waiting = false;
         for (PanelView pv : mPanels) {
             if (animate && !pv.isFullyCollapsed()) {
-                pv.collapse();
+                pv.collapse(true /* delayed */);
                 waiting = true;
             } else {
                 pv.resetViews();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 469a831..c8e943e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -99,6 +99,7 @@
     };
 
     protected void onExpandingFinished() {
+        mClosing = false;
         mBar.onExpandingFinished();
     }
 
@@ -150,7 +151,7 @@
                     postOnAnimation(new Runnable() {
                         @Override
                         public void run() {
-                            collapse();
+                            collapse(false /* delayed */);
                         }
                     });
                 }
@@ -651,7 +652,7 @@
         mBar = panelBar;
     }
 
-    public void collapse() {
+    public void collapse(boolean delayed) {
         if (DEBUG) logf("collapse: " + this);
         if (mPeekPending || mPeekAnimator != null) {
             mCollapseAfterPeek = true;
@@ -668,7 +669,16 @@
             }
             mClosing = true;
             notifyExpandingStarted();
-            fling(0, false /* expand */);
+            if (delayed) {
+                postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        fling(0, false /* expand */);
+                    }
+                }, 120);
+            } else {
+                fling(0, false /* expand */);
+            }
         }
     }
 
@@ -856,7 +866,7 @@
     private final Runnable mPostCollapseRunnable = new Runnable() {
         @Override
         public void run() {
-            collapse();
+            collapse(false /* delayed */);
         }
     };
     private boolean onMiddleClicked() {
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 caecf1d..6470752 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -113,7 +113,6 @@
 import com.android.systemui.doze.DozeService;
 import com.android.systemui.keyguard.KeyguardViewMediator;
 import com.android.systemui.qs.QSPanel;
-import com.android.systemui.qs.QSTile;
 import com.android.systemui.statusbar.ActivatableNotificationView;
 import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.CommandQueue;
@@ -323,7 +322,7 @@
     VelocityTracker mVelocityTracker;
 
     int[] mAbsPos = new int[2];
-    Runnable mPostCollapseCleanup = null;
+    ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>();
 
     // for disabling the status bar
     int mDisabled = 0;
@@ -395,7 +394,6 @@
     private int mNavigationBarMode;
     private Boolean mScreenOn;
 
-    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
     private ViewMediatorCallback mKeyguardViewMediatorCallback;
     private ScrimController mScrimController;
 
@@ -575,6 +573,7 @@
 
         mDozeServiceHost = new DozeServiceHost();
         putComponent(DozeService.Host.class, mDozeServiceHost);
+        putComponent(PhoneStatusBar.class, this);
 
         setControllerUsers();
     }
@@ -887,14 +886,14 @@
             return;
         }
 
-        mPostCollapseCleanup = new Runnable() {
+        addPostCollapseAction(new Runnable() {
             @Override
             public void run() {
                 try {
                     mBarService.onClearAllNotifications(mCurrentUserId);
                 } catch (Exception ex) { }
             }
-        };
+        });
 
         performDismissAllAnimations(viewsToHide);
 
@@ -1366,6 +1365,17 @@
     private void updateNotificationShade() {
         if (mStackScroller == null) return;
 
+        // Do not modify the notifications during collapse.
+        if (isCollapsing()) {
+            addPostCollapseAction(new Runnable() {
+                @Override
+                public void run() {
+                    updateNotificationShade();
+                }
+            });
+            return;
+        }
+
         ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
         ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size());
         final int N = activeNotifications.size();
@@ -2004,8 +2014,8 @@
     }
 
     @Override
-    public void startActivity(Intent intent) {
-        startActivityDismissingKeyguard(intent, false);
+    public void startActivity(Intent intent, boolean dismissShade) {
+        startActivityDismissingKeyguard(intent, false, dismissShade);
     }
 
     public ScrimController getScrimController() {
@@ -2126,10 +2136,7 @@
     public void animateCollapsePanels(int flags, boolean force) {
         if (!force &&
                 (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
-            if (mPostCollapseCleanup != null) {
-                mPostCollapseCleanup.run();
-                mPostCollapseCleanup = null;
-            }
+            runPostCollapseRunnables();
             return;
         }
         if (SPEW) {
@@ -2159,6 +2166,14 @@
         }
     }
 
+    private void runPostCollapseRunnables() {
+        int size = mPostCollapseRunnables.size();
+        for (int i = 0; i < size; i++) {
+            mPostCollapseRunnables.get(i).run();
+        }
+        mPostCollapseRunnables.clear();
+    }
+
     public ViewPropertyAnimator setVisibilityWhenDone(
             final ViewPropertyAnimator a, final View v, final int vis) {
         a.setListener(new AnimatorListenerAdapter() {
@@ -2270,11 +2285,7 @@
         // Close any "App info" popups that might have snuck on-screen
         dismissPopups();
 
-        if (mPostCollapseCleanup != null) {
-            mPostCollapseCleanup.run();
-            mPostCollapseCleanup = null;
-        }
-
+        runPostCollapseRunnables();
         setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
         showBouncer();
         disable(mDisabledUnmodified, true /* animate */);
@@ -2874,7 +2885,8 @@
         }
     }
 
-    public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned) {
+    public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned,
+            final boolean dismissShade) {
         if (onlyProvisioned && !isDeviceProvisioned()) return;
 
         final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
@@ -2884,32 +2896,27 @@
                 AsyncTask.execute(new Runnable() {
                     public void run() {
                         try {
+                            if (keyguardShowing) {
+                                ActivityManagerNative.getDefault()
+                                        .keyguardWaitingForActivityDrawn();
+                            }
                             intent.setFlags(
                                     Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                             mContext.startActivityAsUser(
                                     intent, new UserHandle(UserHandle.USER_CURRENT));
-                            if (keyguardShowing) {
-                                mWindowManagerService.overridePendingAppTransition(
-                                        null, 0, 0, null);
-                            }
+                            overrideActivityPendingAppTransition(keyguardShowing);
                         } catch (RemoteException e) {
                         }
                     }
                 });
-                animateCollapsePanels();
-
-                return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+                if (dismissShade) {
+                    animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+                }
+                return true;
             }
         });
     }
 
-    private View.OnClickListener mClockClickListener = new View.OnClickListener() {
-        public void onClick(View v) {
-            startActivityDismissingKeyguard(
-                    new Intent(Intent.ACTION_QUICK_CLOCK), true); // have fun, everyone
-        }
-    };
-
     private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             if (DEBUG) Log.v(TAG, "onReceive: " + intent);
@@ -2928,6 +2935,7 @@
                 notifyHeadsUpScreenOn(false);
                 finishBarAnimations();
                 stopNotificationLogging();
+                resetUserExpandedStates();
             }
             else if (Intent.ACTION_SCREEN_ON.equals(action)) {
                 mScreenOn = true;
@@ -2956,6 +2964,17 @@
         }
     };
 
+    private void resetUserExpandedStates() {
+        ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
+        final int notificationCount = activeNotifications.size();
+        for (int i = 0; i < notificationCount; i++) {
+            NotificationData.Entry entry = activeNotifications.get(i);
+            if (entry.row != null) {
+                entry.row.resetUserExpansion();
+            }
+        }
+    }
+
     @Override
     protected void dismissKeyguardThenExecute(final OnDismissAction action) {
         if (mStatusBarKeyguardViewManager.isShowing()) {
@@ -3208,19 +3227,7 @@
     }
 
     private void handleStartSettingsActivity(Intent intent, boolean onlyProvisioned) {
-        if (onlyProvisioned && !isDeviceProvisioned()) return;
-        try {
-            // Dismiss the lock screen when Settings starts.
-            ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
-        } catch (RemoteException e) {
-        }
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
-        animateCollapsePanels();
-    }
-
-    public void startSettingsActivity(String action) {
-        postStartSettingsActivity(new Intent(action), 0);
+        startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */);
     }
 
     private static class FastColorDrawable extends Drawable {
@@ -3363,6 +3370,14 @@
         }
     }
 
+    public boolean isCollapsing() {
+        return mNotificationPanel.isCollapsing();
+    }
+
+    public void addPostCollapseAction(Runnable r) {
+        mPostCollapseRunnables.add(r);
+    }
+
     public boolean isInLaunchTransition() {
         return mNotificationPanel.isLaunchTransitionRunning()
                 || mNotificationPanel.isLaunchTransitionFinished();
@@ -3603,10 +3618,7 @@
     }
 
     public void onTrackingStarted() {
-        if (mPostCollapseCleanup != null) {
-            mPostCollapseCleanup.run();
-            mPostCollapseCleanup = null;
-        }
+        runPostCollapseRunnables();
     }
 
     public void onUnlockHintStarted() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index 0c62fd3..85aa00d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -483,17 +483,19 @@
         } else if (v == mAlarmStatus && mNextAlarm != null) {
             PendingIntent showIntent = mNextAlarm.getShowIntent();
             if (showIntent != null && showIntent.isActivity()) {
-                mActivityStarter.startActivity(showIntent.getIntent());
+                mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */);
             }
         }
     }
 
     private void startSettingsActivity() {
-        mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
+        mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS),
+                true /* dismissShade */);
     }
 
     private void startBatteryActivity() {
-        mActivityStarter.startActivity(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY));
+        mActivityStarter.startActivity(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY),
+                true /* dismissShade */);
     }
 
     public void setQSPanel(QSPanel qsp) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 68dd4f9..b03e6c0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -206,12 +206,13 @@
      * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the
      * security view of the bouncer.
      *
-     * @param finishRunnable the runnable to be run after the animation finished
+     * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
+     *                       no action should be run
      */
     public void startPreHideAnimation(Runnable finishRunnable) {
         if (mBouncer.isShowing()) {
             mBouncer.startPreHideAnimation(finishRunnable);
-        } else {
+        } else if (finishRunnable != null) {
             finishRunnable.run();
         }
     }
@@ -362,4 +363,17 @@
     public boolean interceptMediaKey(KeyEvent event) {
         return mBouncer.interceptMediaKey(event);
     }
+
+    public void onActivityDrawn() {
+        if (mPhoneStatusBar.isCollapsing()) {
+            mPhoneStatusBar.addPostCollapseAction(new Runnable() {
+                @Override
+                public void run() {
+                    mViewMediatorCallback.readyForKeyguardDone();
+                }
+            });
+        } else {
+            mViewMediatorCallback.readyForKeyguardDone();
+        }
+    }
 }
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 d25dda1..462452b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -211,6 +211,15 @@
     public NotificationStackScrollLayout(Context context, AttributeSet attrs, int defStyleAttr,
             int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
+        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
+        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
+        mExpandHelper = new ExpandHelper(getContext(), this,
+                minHeight, maxHeight);
+        mExpandHelper.setEventSource(this);
+        mExpandHelper.setScrollAdapter(this);
+
+        mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, getContext());
+        mSwipeHelper.setLongPressListener(mLongPressListener);
         initView(context);
         if (DEBUG) {
             setWillNotDraw(false);
@@ -248,10 +257,6 @@
         mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
         mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
         mOverflingDistance = configuration.getScaledOverflingDistance();
-        float densityScale = getResources().getDisplayMetrics().density;
-        float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
-        mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, getContext());
-        mSwipeHelper.setLongPressListener(mLongPressListener);
 
         mSidePaddings = context.getResources()
                 .getDimensionPixelSize(R.dimen.notification_side_padding);
@@ -266,12 +271,6 @@
         mPaddingBetweenElementsNormal = context.getResources()
                 .getDimensionPixelSize(R.dimen.notification_padding);
         updatePadding(mAmbientState.isDimmed());
-        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
-        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
-        mExpandHelper = new ExpandHelper(getContext(), this,
-                minHeight, maxHeight);
-        mExpandHelper.setEventSource(this);
-        mExpandHelper.setScrollAdapter(this);
         mMinTopOverScrollToEscape = getResources().getDimensionPixelSize(
                 R.dimen.min_top_overscroll_to_qs);
         mNotificationTopPadding = getResources().getDimensionPixelSize(
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 04a3b88..0586a83 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -1,6 +1,5 @@
 package com.android.systemui.volume;
 
-import android.app.ActivityManagerNative;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
@@ -18,10 +17,12 @@
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.Log;
+import android.view.WindowManagerGlobal;
 
 import com.android.systemui.R;
 import com.android.systemui.SystemUI;
 import com.android.systemui.keyguard.KeyguardViewMediator;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
 import com.android.systemui.statusbar.policy.ZenModeController;
 import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
 
@@ -138,22 +139,8 @@
     private final Runnable mStartZenSettings = new Runnable() {
         @Override
         public void run() {
-            AsyncTask.execute(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        // Dismiss the lock screen when Settings starts.
-                        ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
-                    } catch (RemoteException e) {
-                    }
-                    final Intent intent = ZenModePanel.ZEN_SETTINGS;
-                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-                    mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
-
-                    // dismiss shade if showing
-                    mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
-                }
-            });
+            getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(
+                    ZenModePanel.ZEN_SETTINGS, true /* onlyProvisioned */, true /* dismissShade */);
             mPanel.postDismiss(mDismissDelay);
         }
     };
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index ca260ec..7efda1a 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -4766,13 +4766,19 @@
             mHandler.post(new Runnable() {
                 @Override
                 public void run() {
-                    if (mKeyguardDelegate.isDismissable()) {
-                        // Can we just finish the keyguard straight away?
-                        mKeyguardDelegate.keyguardDone(false, true);
-                    } else {
-                        // ask the keyguard to prompt the user to authenticate if necessary
-                        mKeyguardDelegate.dismiss();
-                    }
+                    // ask the keyguard to prompt the user to authenticate if necessary
+                    mKeyguardDelegate.dismiss();
+                }
+            });
+        }
+    }
+
+    public void notifyActivityDrawnForKeyguardLw() {
+        if (mKeyguardDelegate != null) {
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    mKeyguardDelegate.onActivityDrawn();
                 }
             });
         }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
index 63a5850..aac02ad 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
@@ -334,4 +334,9 @@
         mKeyguardState.bootCompleted = true;
     }
 
+    public void onActivityDrawn() {
+        if (mKeyguardService != null) {
+            mKeyguardService.onActivityDrawn();
+        }
+    }
 }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
index 5096bd3..2778b15 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
@@ -198,6 +198,14 @@
         }
     }
 
+    public void onActivityDrawn() {
+        try {
+            mService.onActivityDrawn();
+        } catch (RemoteException e) {
+            Slog.w(TAG , "Remote Exception", e);
+        }
+    }
+
     public void showAssistant() {
         // Not used by PhoneWindowManager
     }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 6054401..6ca64d3 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5639,17 +5639,13 @@
     }
 
     @Override
-    public void dismissKeyguardOnNextActivity() {
-        enforceNotIsolatedCaller("dismissKeyguardOnNextActivity");
+    public void keyguardWaitingForActivityDrawn() {
+        enforceNotIsolatedCaller("keyguardWaitingForActivityDrawn");
         final long token = Binder.clearCallingIdentity();
         try {
             synchronized (this) {
                 if (DEBUG_LOCKSCREEN) logLockScreen("");
-                if (mLockScreenShown) {
-                    mLockScreenShown = false;
-                    comeOutOfSleepIfNeededLocked();
-                }
-                mStackSupervisor.setDismissKeyguard(true);
+                mWindowManager.keyguardWaitingForActivityDrawn();
             }
         } finally {
             Binder.restoreCallingIdentity(token);
@@ -9263,8 +9259,7 @@
     void logLockScreen(String msg) {
         if (DEBUG_LOCKSCREEN) Slog.d(TAG, Debug.getCallers(2) + ":" + msg +
                 " mLockScreenShown=" + mLockScreenShown + " mWentToSleep=" +
-                mWentToSleep + " mSleeping=" + mSleeping + " mDismissKeyguardOnNextActivity=" +
-                mStackSupervisor.mDismissKeyguardOnNextActivity);
+                mWentToSleep + " mSleeping=" + mSleeping);
     }
 
     private void comeOutOfSleepIfNeededLocked() {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 4653742..3f02184 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -46,7 +46,6 @@
 import com.android.server.Watchdog;
 import com.android.server.am.ActivityManagerService.ItemMatcher;
 import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
-import com.android.server.am.ActivityStackSupervisor.ActivityDisplay;
 import com.android.server.wm.AppTransition;
 import com.android.server.wm.TaskGroup;
 import com.android.server.wm.WindowManagerService;
@@ -1059,7 +1058,7 @@
 
         if (next.nowVisible) {
             // We won't get a call to reportActivityVisibleLocked() so dismiss lockscreen now.
-            mStackSupervisor.dismissKeyguard();
+            mStackSupervisor.notifyActivityDrawnForKeyguard();
         }
 
         // schedule an idle timeout in case the app doesn't do it for us.
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 3d23cb7..91cfd78 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -167,9 +167,6 @@
     WindowManagerService mWindowManager;
     DisplayManager mDisplayManager;
 
-    /** Dismiss the keyguard after the next activity is displayed? */
-    boolean mDismissKeyguardOnNextActivity = false;
-
     /** Identifier counter for all ActivityStacks */
     private int mLastStackId = HOME_STACK_ID;
 
@@ -363,12 +360,9 @@
         }
     }
 
-    void dismissKeyguard() {
+    void notifyActivityDrawnForKeyguard() {
         if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen("");
-        if (mDismissKeyguardOnNextActivity) {
-            mDismissKeyguardOnNextActivity = false;
-            mWindowManager.dismissKeyguard();
-        }
+        mWindowManager.notifyActivityDrawnForKeyguard();
     }
 
     ActivityStack getFocusedStack() {
@@ -439,9 +433,8 @@
         return mService.startHomeActivityLocked(mCurrentUser);
     }
 
-    void setDismissKeyguard(boolean dismiss) {
-        if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen(" dismiss=" + dismiss);
-        mDismissKeyguardOnNextActivity = dismiss;
+    void keyguardWaitingForActivityDrawn() {
+        mWindowManager.keyguardWaitingForActivityDrawn();
     }
 
     TaskRecord anyTaskForIdLocked(int id) {
@@ -660,7 +653,7 @@
             w.thisTime = w.totalTime;
         }
         mService.notifyAll();
-        dismissKeyguard();
+        notifyActivityDrawnForKeyguard();
     }
 
     void reportActivityLaunchedLocked(boolean timeout, ActivityRecord r,
@@ -1371,7 +1364,6 @@
                     resultRecord, resultWho, requestCode,
                     Activity.RESULT_CANCELED, null);
             }
-            setDismissKeyguard(false);
             ActivityOptions.abort(options);
             return err;
         }
@@ -1386,7 +1378,6 @@
                     resultRecord, resultWho, requestCode,
                     Activity.RESULT_CANCELED, null);
             }
-            setDismissKeyguard(false);
             String msg;
             if (!aInfo.exported) {
                 msg = "Permission Denial: starting " + intent.toString()
@@ -1425,7 +1416,6 @@
             }
             // We pretend to the caller that it was really started, but
             // they will just get a cancel result.
-            setDismissKeyguard(false);
             ActivityOptions.abort(options);
             return ActivityManager.START_SUCCESS;
         }
@@ -1444,7 +1434,6 @@
                 PendingActivityLaunch pal =
                         new PendingActivityLaunch(r, sourceRecord, startFlags, stack);
                 mPendingActivityLaunches.add(pal);
-                setDismissKeyguard(false);
                 ActivityOptions.abort(options);
                 return ActivityManager.START_SWITCHES_CANCELED;
             }
@@ -1466,12 +1455,12 @@
         err = startActivityUncheckedLocked(r, sourceRecord, voiceSession, voiceInteractor,
                 startFlags, true, options);
 
-        if (allPausedActivitiesComplete()) {
+        if (err < 0) {
             // If someone asked to have the keyguard dismissed on the next
             // activity start, but we are not actually doing an activity
             // switch...  just dismiss the keyguard now, because we
             // probably want to see whatever is behind it.
-            dismissKeyguard();
+            notifyActivityDrawnForKeyguard();
         }
         return err;
     }
@@ -2852,8 +2841,6 @@
     }
 
     public void dump(PrintWriter pw, String prefix) {
-        pw.print(prefix); pw.print("mDismissKeyguardOnNextActivity=");
-                pw.println(mDismissKeyguardOnNextActivity);
         pw.print(prefix); pw.print("mFocusedStack=" + mFocusedStack);
                 pw.print(" mLastFocusedStack="); pw.println(mLastFocusedStack);
         pw.print(prefix); pw.println("mSleepTimeout=" + mSleepTimeout);
diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
index 72ac29a..e39f0b1 100644
--- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
@@ -265,7 +265,7 @@
                     mInfo.flags |= DisplayDeviceInfo.FLAG_PRIVATE
                             | DisplayDeviceInfo.FLAG_NEVER_BLANK;
                 }
-                if ((mInfo.flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) {
+                if ((mFlags & DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) {
                     mInfo.flags &= ~DisplayDeviceInfo.FLAG_NEVER_BLANK;
                 } else {
                     mInfo.flags |= DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY;
diff --git a/services/core/java/com/android/server/hdmi/Constants.java b/services/core/java/com/android/server/hdmi/Constants.java
index 591cf25..2407253 100644
--- a/services/core/java/com/android/server/hdmi/Constants.java
+++ b/services/core/java/com/android/server/hdmi/Constants.java
@@ -258,6 +258,12 @@
     static final int MHL_RAP_ACTION_CONTENT_ON = 0x10;
     static final int MHL_RAP_ACTION_CONTENT_OFF = 0x11;
 
+    // MHL RAPK messages.
+    static final int MHL_RAPK_NO_ERROR = 0x00;
+    static final int MHL_RAPK_UNRECOGNIZED_ACTION = 0x01;
+    static final int MHL_RAPK_UNSUPPORTED_ACTION = 0x02;
+    static final int MHL_RAPK_RESPONDER_BUSY = 0x03;
+
     static final int MHL_INVALID_ADOPTER_ID = -1;
     static final int MHL_INVALID_DEVICE_ID = -1;
 
diff --git a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java
index ed37ead..d155e84 100644
--- a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java
+++ b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java
@@ -23,7 +23,6 @@
 import android.os.RemoteException;
 import android.util.Slog;
 
-import com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource;
 import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
 
 /**
@@ -42,9 +41,6 @@
     // Time in milliseconds we wait for the device power status to turn to 'On'.
     private static final int TIMEOUT_POWER_ON_MS = 5 * 1000;
 
-    // Time in milliseconds we wait for <Active Source>.
-    private static final int TIMEOUT_ACTIVE_SOURCE_MS = 20 * 1000;
-
     // The number of times we try to wake up the target device before we give up
     // and just send <Set Stream Path>.
     private static final int LOOP_COUNTER_MAX = 20;
@@ -62,11 +58,6 @@
     // maximum 100 seconds (20 * 5) before we give up and just send <Set Stream Path>.
     private static final int STATE_WAIT_FOR_DEVICE_POWER_ON = 3;
 
-    // State in which we wait for the <Active Source> in response to the command
-    // <Set Stream Path> we have sent. We wait as much as TIMEOUT_ACTIVE_SOURCE_MS
-    // before we give up and mark the action as failure.
-    private static final int STATE_WAIT_FOR_ACTIVE_SOURCE = 4;
-
     private final HdmiDeviceInfo mTarget;
     private final IHdmiControlCallback mCallback;
     private final HdmiCecMessage mGivePowerStatus;
@@ -129,16 +120,6 @@
                     return handleReportPowerStatus(params[0]);
                 }
                 return false;
-            case STATE_WAIT_FOR_ACTIVE_SOURCE:
-                if (opcode == Constants.MESSAGE_ACTIVE_SOURCE) {
-                    int physicalAddress = HdmiUtils.twoBytesToInt(params);
-                    ActiveSourceHandler
-                            .create((HdmiCecLocalDeviceTv) localDevice(), mCallback)
-                            .process(ActiveSource.of(cmd.getSource(), physicalAddress));
-                    finish();
-                    return true;
-                }
-                return false;
             default:
                 break;
         }
@@ -189,8 +170,8 @@
     private void sendSetStreamPath() {
         sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(
                 getSourceAddress(), mTarget.getPhysicalAddress()));
-        mState = STATE_WAIT_FOR_ACTIVE_SOURCE;
-        addTimer(mState, TIMEOUT_ACTIVE_SOURCE_MS);
+        invokeCallback(HdmiControlManager.RESULT_SUCCESS);
+        finish();
     }
 
     @Override
@@ -213,10 +194,6 @@
                 mPowerStatusCounter++;
                 queryDevicePowerStatus();
                 break;
-            case STATE_WAIT_FOR_ACTIVE_SOURCE:
-                invokeCallback(HdmiControlManager.RESULT_TIMEOUT);
-                finish();
-                break;
         }
     }
 
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index 0e57afd..e49d831 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -198,6 +198,10 @@
     @GuardedBy("mLock")
     private boolean mProhibitMode;
 
+    // Set to true while the input change by MHL is allowed.
+    @GuardedBy("mLock")
+    private boolean mMhlInputChangeEnabled;
+
     // List of listeners registered by callers that want to get notified of
     // system audio mode changes.
     private final ArrayList<IHdmiSystemAudioModeChangeListener>
@@ -269,6 +273,7 @@
         mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
         mProhibitMode = false;
         mHdmiControlEnabled = readBooleanSetting(Global.HDMI_CONTROL_ENABLED, true);
+        mMhlInputChangeEnabled = readBooleanSetting(Global.MHL_INPUT_SWITCHING_ENABLED, true);
 
         mCecController = HdmiCecController.create(this);
         if (mCecController != null) {
@@ -353,10 +358,12 @@
                     // No need to propagate to HAL.
                     break;
                 case Global.MHL_INPUT_SWITCHING_ENABLED:
-                    setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled));
+                    setMhlInputChangeEnabled(enabled);
                     break;
                 case Global.MHL_POWER_CHARGE_ENABLED:
-                    setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled));
+                    if (mMhlController != null) {
+                        mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled));
+                    }
                     break;
             }
         }
@@ -1741,4 +1748,20 @@
         assertRunOnServiceThread();
         mActivePortId = portId;
     }
+
+    void setMhlInputChangeEnabled(boolean enabled) {
+        if (mMhlController != null) {
+            mMhlController.setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled));
+        }
+
+        synchronized (mLock) {
+            mMhlInputChangeEnabled = enabled;
+        }
+    }
+
+    boolean isMhlInputChangeEnabled() {
+        synchronized (mLock) {
+            return mMhlInputChangeEnabled;
+        }
+    }
 }
diff --git a/services/core/java/com/android/server/location/GpsLocationProvider.java b/services/core/java/com/android/server/location/GpsLocationProvider.java
index 058a23e..201d9b4 100644
--- a/services/core/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/core/java/com/android/server/location/GpsLocationProvider.java
@@ -221,6 +221,14 @@
     private static final int GPS_GEOFENCE_ERROR_INVALID_TRANSITION = -103;
     private static final int GPS_GEOFENCE_ERROR_GENERIC = -149;
 
+    // Value of batterySaverGpsMode such that GPS isn't affected by battery saver mode.
+    private static final int BATTERY_SAVER_MODE_NO_CHANGE = 0;
+    // Value of batterySaverGpsMode such that GPS is disabled when battery saver mode
+    // is enabled and the screen is off.
+    private static final int BATTERY_SAVER_MODE_DISABLED_WHEN_SCREEN_OFF = 1;
+    // Secure setting for GPS behavior when battery saver mode is on.
+    private static final String BATTERY_SAVER_GPS_MODE = "batterySaverGpsMode";
+
     /** simpler wrapper for ProviderRequest + Worksource */
     private static class GpsRequest {
         public ProviderRequest request;
@@ -308,6 +316,13 @@
 
     private int mPositionMode;
 
+    // Current request from underlying location clients.
+    private ProviderRequest mProviderRequest = null;
+    // Current list of underlying location clients.
+    private WorkSource mWorkSource = null;
+    // True if gps should be disabled (used to support battery saver mode in settings).
+    private boolean mDisableGps = false;
+
     // properties loaded from PROPERTIES_FILE
     private Properties mProperties;
     private String mSuplServerHost;
@@ -352,6 +367,7 @@
     // Alarms
     private final static String ALARM_WAKEUP = "com.android.internal.location.ALARM_WAKEUP";
     private final static String ALARM_TIMEOUT = "com.android.internal.location.ALARM_TIMEOUT";
+    private final PowerManager mPowerManager;
     private final AlarmManager mAlarmManager;
     private final PendingIntent mWakeupIntent;
     private final PendingIntent mTimeoutIntent;
@@ -441,23 +457,27 @@
                 checkSmsSuplInit(intent);
             } else if (action.equals(Intents.WAP_PUSH_RECEIVED_ACTION)) {
                 checkWapSuplInit(intent);
-             } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
-                 int networkState;
-                 if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
-                     networkState = LocationProvider.TEMPORARILY_UNAVAILABLE;
-                 } else {
-                     networkState = LocationProvider.AVAILABLE;
-                 }
+            } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+                int networkState;
+                if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
+                    networkState = LocationProvider.TEMPORARILY_UNAVAILABLE;
+                } else {
+                    networkState = LocationProvider.AVAILABLE;
+                }
 
-                 // retrieve NetworkInfo result for this UID
-                 NetworkInfo info =
-                         intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
-                 ConnectivityManager connManager = (ConnectivityManager)
-                         mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
-                 info = connManager.getNetworkInfo(info.getType());
+                // retrieve NetworkInfo result for this UID
+                NetworkInfo info =
+                        intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
+                ConnectivityManager connManager = (ConnectivityManager)
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+                info = connManager.getNetworkInfo(info.getType());
 
-                 updateNetworkState(networkState, info);
-             }
+                updateNetworkState(networkState, info);
+            } else if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)
+                    || Intent.ACTION_SCREEN_OFF.equals(action)
+                    || Intent.ACTION_SCREEN_ON.equals(action)) {
+                updateLowPowerMode();
+            }
         }
     };
 
@@ -474,6 +494,22 @@
         native_agps_ni_message(supl_init,supl_init.length);
     }
 
+    private void updateLowPowerMode() {
+        final boolean disableGps;
+        switch (Settings.Secure.getInt(mContext.getContentResolver(), BATTERY_SAVER_GPS_MODE,
+                BATTERY_SAVER_MODE_DISABLED_WHEN_SCREEN_OFF)) {
+            case BATTERY_SAVER_MODE_DISABLED_WHEN_SCREEN_OFF:
+                disableGps = mPowerManager.isPowerSaveMode() && !mPowerManager.isInteractive();
+                break;
+            default:
+                disableGps = false;
+        }
+        if (disableGps != mDisableGps) {
+            mDisableGps = disableGps;
+            updateRequirements();
+        }
+    }
+
     public static boolean isSupported() {
         return native_is_supported();
     }
@@ -526,8 +562,8 @@
         mLocation.setExtras(mLocationExtras);
 
         // Create a wake lock
-        PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
-        mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY);
+        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+        mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY);
         mWakeLock.setReferenceCounted(true);
 
         mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
@@ -604,6 +640,9 @@
         intentFilter.addAction(ALARM_WAKEUP);
         intentFilter.addAction(ALARM_TIMEOUT);
         intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+        intentFilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
+        intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
+        intentFilter.addAction(Intent.ACTION_SCREEN_ON);
         mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
     }
 
@@ -888,31 +927,43 @@
     }
 
     private void handleSetRequest(ProviderRequest request, WorkSource source) {
+        mProviderRequest = request;
+        mWorkSource = source;
+        updateRequirements();
+    }
+
+    // Called when the requirements for GPS may have changed
+    private void updateRequirements() {
+        if (mProviderRequest == null || mWorkSource == null) {
+            return;
+        }
+
         boolean singleShot = false;
 
         // see if the request is for a single update
-        if (request.locationRequests != null && request.locationRequests.size() > 0) {
+        if (mProviderRequest.locationRequests != null
+                && mProviderRequest.locationRequests.size() > 0) {
             // if any request has zero or more than one updates
             // requested, then this is not single-shot mode
             singleShot = true;
 
-            for (LocationRequest lr : request.locationRequests) {
+            for (LocationRequest lr : mProviderRequest.locationRequests) {
                 if (lr.getNumUpdates() != 1) {
                     singleShot = false;
                 }
             }
         }
 
-        if (DEBUG) Log.d(TAG, "setRequest " + request);
-        if (request.reportLocation) {
+        if (DEBUG) Log.d(TAG, "setRequest " + mProviderRequest);
+        if (mProviderRequest.reportLocation && !mDisableGps) {
             // update client uids
-            updateClientUids(source);
+            updateClientUids(mWorkSource);
 
-            mFixInterval = (int) request.interval;
+            mFixInterval = (int) mProviderRequest.interval;
 
             // check for overflow
-            if (mFixInterval != request.interval) {
-                Log.w(TAG, "interval overflow: " + request.interval);
+            if (mFixInterval != mProviderRequest.interval) {
+                Log.w(TAG, "interval overflow: " + mProviderRequest.interval);
                 mFixInterval = Integer.MAX_VALUE;
             }
 
@@ -1909,6 +1960,7 @@
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         StringBuilder s = new StringBuilder();
         s.append("  mFixInterval=").append(mFixInterval).append("\n");
+        s.append("  mDisableGps (battery saver mode)=").append(mDisableGps).append("\n");
         s.append("  mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)).append(" (");
         if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHED ");
         if (hasCapability(GPS_CAPABILITY_MSB)) s.append("MSB ");
@@ -2000,3 +2052,4 @@
     private native boolean native_start_navigation_message_collection();
     private native boolean native_stop_navigation_message_collection();
 }
+
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 87468d2..d6afe68 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2425,8 +2425,9 @@
                 // pulse repeatedly
                 mNotificationLight.setFlashing(ledARGB, Light.LIGHT_FLASH_TIMED,
                         ledOnMS, ledOffMS);
-                mStatusBar.notificationLightPulse(ledARGB, ledOnMS, ledOffMS);
             }
+            // let SystemUI make an independent decision
+            mStatusBar.notificationLightPulse(ledARGB, ledOnMS, ledOffMS);
         }
     }
 
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 6be6b60..89bd1d4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -253,6 +253,10 @@
     // package apks to install directory.
     private static final String INSTALL_PACKAGE_SUFFIX = "-";
 
+    // Special value for {@code PackageParser.Package#cpuAbiOverride} to indicate
+    // that the cpuAbiOverride must be clear.
+    private static final String CLEAR_ABI_OVERRIDE = "-";
+
     static final int SCAN_MONITOR = 1<<0;
     static final int SCAN_NO_DEX = 1<<1;
     static final int SCAN_FORCE_DEX = 1<<2;
@@ -3195,7 +3199,7 @@
         if (fromSource != null) {
             packageNames = fromSource.get(targetUserId);
         }
-        if (packageNames.contains(intent.getPackage())) {
+        if (packageNames != null && packageNames.contains(intent.getPackage())) {
             return true;
         }
         // We need the package name, so we try to resolve with the loosest flags possible
@@ -4093,8 +4097,7 @@
                 continue;
             }
             try {
-                scanPackageLI(file, flags | PackageParser.PARSE_MUST_BE_APK, scanMode, currentTime,
-                        null, null);
+                scanPackageLI(file, flags | PackageParser.PARSE_MUST_BE_APK, scanMode, currentTime, null);
             } catch (PackageManagerException e) {
                 Slog.w(TAG, "Failed to parse " + file + ": " + e.getMessage());
 
@@ -4175,7 +4178,7 @@
      *  Returns null in case of errors and the error code is stored in mLastScanError
      */
     private PackageParser.Package scanPackageLI(File scanFile, int parseFlags, int scanMode,
-            long currentTime, UserHandle user, String abiOverride) throws PackageManagerException {
+            long currentTime, UserHandle user) throws PackageManagerException {
         if (DEBUG_INSTALL) Slog.d(TAG, "Parsing: " + scanFile);
         parseFlags |= mDefParseFlags;
         PackageParser pp = new PackageParser();
@@ -4371,7 +4374,7 @@
 
         // Note that we invoke the following method only if we are about to unpack an application
         PackageParser.Package scannedPkg = scanPackageLI(pkg, parseFlags, scanMode
-                | SCAN_UPDATE_SIGNATURE, currentTime, user, abiOverride);
+                | SCAN_UPDATE_SIGNATURE, currentTime, user);
 
         /*
          * If the system app should be overridden by a previously installed
@@ -4998,8 +5001,26 @@
         return res;
     }
 
+    /**
+     * Derive the value of the {@code cpuAbiOverride} based on the provided
+     * value and an optional stored value from the package settings.
+     */
+    private static String deriveAbiOverride(String abiOverride, PackageSetting settings) {
+        String cpuAbiOverride = null;
+
+        if (CLEAR_ABI_OVERRIDE.equals(abiOverride)) {
+            cpuAbiOverride = null;
+        } else if (abiOverride != null) {
+            cpuAbiOverride = abiOverride;
+        } else if (settings != null) {
+            cpuAbiOverride = settings.cpuAbiOverrideString;
+        }
+
+        return cpuAbiOverride;
+    }
+
     private PackageParser.Package scanPackageLI(PackageParser.Package pkg, int parseFlags,
-            int scanMode, long currentTime, UserHandle user, String abiOverride)
+            int scanMode, long currentTime, UserHandle user)
             throws PackageManagerException {
         final File scanFile = new File(pkg.codePath);
         if (pkg.applicationInfo.getCodePath() == null ||
@@ -5155,7 +5176,7 @@
                 Slog.w(TAG, "Package " + pkg.packageName
                         + " was transferred to another, but its .apk remains");
             }
-            
+
             // Just create the setting, don't add it yet. For already existing packages
             // the PkgSetting exists already and doesn't have to be created.
             pkgSetting = mSettings.getPackageLPw(pkg, origPackage, realName, suid, destCodeFile,
@@ -5435,14 +5456,8 @@
 
         final String path = scanFile.getPath();
         final String codePath = pkg.applicationInfo.getCodePath();
+        final String cpuAbiOverride = deriveAbiOverride(pkg.cpuAbiOverride, pkgSetting);
         if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
-            // For the case where we had previously uninstalled an update, get rid
-            // of any native binaries we might have unpackaged. Note that this assumes
-            // that system app updates were not installed via ASEC.
-            //
-            // TODO(multiArch): Is this cleanup really necessary ?
-            NativeLibraryHelper.removeNativeBinariesFromDirLI(
-                    new File(codePath, LIB_DIR_NAME), false /* delete dirs */);
             setBundledAppAbisAndRoots(pkg, pkgSetting);
 
             // If we haven't found any native libraries for the app, check if it has
@@ -5497,7 +5512,7 @@
                     // Warn if we've set an abiOverride for multi-lib packages..
                     // By definition, we need to copy both 32 and 64 bit libraries for
                     // such packages.
-                    if (abiOverride != null) {
+                    if (pkg.cpuAbiOverride != null && !CLEAR_ABI_OVERRIDE.equals(pkg.cpuAbiOverride)) {
                         Slog.w(TAG, "Ignoring abiOverride for multi arch application.");
                     }
 
@@ -5540,15 +5555,15 @@
                         }
                     }
                 } else {
-                    String[] abiList = (abiOverride != null) ?
-                            new String[] { abiOverride } : Build.SUPPORTED_ABIS;
+                    String[] abiList = (cpuAbiOverride != null) ?
+                            new String[] { cpuAbiOverride } : Build.SUPPORTED_ABIS;
 
                     // Enable gross and lame hacks for apps that are built with old
                     // SDK tools. We must scan their APKs for renderscript bitcode and
                     // not launch them if it's present. Don't bother checking on devices
                     // that don't have 64 bit support.
                     boolean needsRenderScriptOverride = false;
-                    if (Build.SUPPORTED_64_BIT_ABIS.length > 0 && abiOverride == null &&
+                    if (Build.SUPPORTED_64_BIT_ABIS.length > 0 && cpuAbiOverride == null &&
                             NativeLibraryHelper.hasRenderscriptBitcode(handle)) {
                         abiList = Build.SUPPORTED_32_BIT_ABIS;
                         needsRenderScriptOverride = true;
@@ -5569,8 +5584,8 @@
 
                     if (copyRet >= 0) {
                         pkg.applicationInfo.primaryCpuAbi = abiList[copyRet];
-                    } else if (copyRet == PackageManager.NO_NATIVE_LIBRARIES && abiOverride != null) {
-                        pkg.applicationInfo.primaryCpuAbi = abiOverride;
+                    } else if (copyRet == PackageManager.NO_NATIVE_LIBRARIES && cpuAbiOverride != null) {
+                        pkg.applicationInfo.primaryCpuAbi = cpuAbiOverride;
                     } else if (needsRenderScriptOverride) {
                         pkg.applicationInfo.primaryCpuAbi = abiList[0];
                     }
@@ -5615,6 +5630,10 @@
 
         pkgSetting.primaryCpuAbiString = pkg.applicationInfo.primaryCpuAbi;
         pkgSetting.secondaryCpuAbiString = pkg.applicationInfo.secondaryCpuAbi;
+        pkgSetting.cpuAbiOverrideString = cpuAbiOverride;
+        // Copy the derived override back to the parsed package, so that we can
+        // update the package settings accordingly.
+        pkg.cpuAbiOverride = cpuAbiOverride;
 
         Slog.d(TAG, "Resolved nativeLibraryRoot for " + pkg.applicationInfo.packageName
                 + " to root=" + pkg.applicationInfo.nativeLibraryRootDir + ", isa="
@@ -6241,7 +6260,7 @@
         }
     }
 
-    private static String calculateApkRoot(final String codePathString) {
+    private static String calculateBundledApkRoot(final String codePathString) {
         final File codePath = new File(codePathString);
         final File codeRoot;
         if (FileUtils.contains(Environment.getRootDirectory(), codePath)) {
@@ -6281,14 +6300,9 @@
         final ApplicationInfo info = pkg.applicationInfo;
         final String codePath = pkg.codePath;
         final File codeFile = new File(codePath);
-        // If "/system/lib64/apkname" exists, assume that is the per-package
-        // native library directory to use; otherwise use "/system/lib/apkname".
-        final String apkRoot = calculateApkRoot(info.sourceDir);
-
         final boolean bundledApp = isSystemApp(info) && !isUpdatedSystemApp(info);
         final boolean asecApp = isForwardLocked(info) || isExternal(info);
 
-
         info.nativeLibraryRootDir = null;
         info.nativeLibraryRootRequiresIsa = false;
         info.nativeLibraryDir = null;
@@ -6297,6 +6311,9 @@
         if (isApkFile(codeFile)) {
             // Monolithic install
             if (bundledApp) {
+                // If "/system/lib64/apkname" exists, assume that is the per-package
+                // native library directory to use; otherwise use "/system/lib/apkname".
+                final String apkRoot = calculateBundledApkRoot(info.sourceDir);
                 final boolean is64Bit = VMRuntime.is64BitInstructionSet(
                         getPrimaryInstructionSet(info));
 
@@ -6352,7 +6369,7 @@
 
         // If "/system/lib64/apkname" exists, assume that is the per-package
         // native library directory to use; otherwise use "/system/lib/apkname".
-        final String apkRoot = calculateApkRoot(pkg.applicationInfo.sourceDir);
+        final String apkRoot = calculateBundledApkRoot(pkg.applicationInfo.sourceDir);
         setBundledAppAbi(pkg, apkRoot, apkName);
         // pkgSetting might be null during rescan following uninstall of updates
         // to a bundled app, so accommodate that possibility.  The settings in
@@ -9278,7 +9295,7 @@
                     // Warn if we've set an abiOverride for multi-lib packages..
                     // By definition, we need to copy both 32 and 64 bit libraries for
                     // such packages.
-                    if (abiOverride != null) {
+                    if (abiOverride != null &&  !CLEAR_ABI_OVERRIDE.equals(abiOverride)) {
                         Slog.w(TAG, "Ignoring abiOverride for multi arch application.");
                     }
 
@@ -9295,10 +9312,11 @@
                         maybeThrowExceptionForMultiArchCopy("Failure copying 64 bit native libraries", copyRet);
                     }
                 } else {
-                    String[] abiList = (abiOverride != null) ?
-                            new String[] { abiOverride } : Build.SUPPORTED_ABIS;
+                    final String cpuAbiOverride = deriveAbiOverride(this.abiOverride, null /* package setting */);
+                    String[] abiList = (cpuAbiOverride != null) ?
+                            new String[] { cpuAbiOverride } : Build.SUPPORTED_ABIS;
 
-                    if (Build.SUPPORTED_64_BIT_ABIS.length > 0 && abiOverride == null &&
+                    if (Build.SUPPORTED_64_BIT_ABIS.length > 0 && cpuAbiOverride == null &&
                             NativeLibraryHelper.hasRenderscriptBitcode(handle)) {
                         abiList = Build.SUPPORTED_32_BIT_ABIS;
                     }
@@ -9566,7 +9584,7 @@
 
             final String newCachePath = imcs.copyPackageToContainer(
                     originFile.getAbsolutePath(), cid, getEncryptKey(), isExternal(),
-                    isFwdLocked(), abiOverride);
+                    isFwdLocked(), deriveAbiOverride(abiOverride, null /* settings */));
 
             if (newCachePath != null) {
                 setCachePath(newCachePath);
@@ -9917,7 +9935,7 @@
      */
     private void installNewPackageLI(PackageParser.Package pkg,
             int parseFlags, int scanMode, UserHandle user,
-            String installerPackageName, PackageInstalledInfo res, String abiOverride) {
+            String installerPackageName, PackageInstalledInfo res) {
         // Remember this for later, in case we need to rollback this install
         String pkgName = pkg.packageName;
 
@@ -9944,7 +9962,7 @@
 
         try {
             PackageParser.Package newPackage = scanPackageLI(pkg, parseFlags, scanMode,
-                    System.currentTimeMillis(), user, abiOverride);
+                    System.currentTimeMillis(), user);
 
             updateSettingsLI(newPackage, installerPackageName, null, null, res);
             // delete the partially installed application. the data directory will have to be
@@ -9980,7 +9998,7 @@
 
     private void replacePackageLI(PackageParser.Package pkg,
             int parseFlags, int scanMode, UserHandle user,
-            String installerPackageName, PackageInstalledInfo res, String abiOverride) {
+            String installerPackageName, PackageInstalledInfo res) {
         PackageParser.Package oldPackage;
         String pkgName = pkg.packageName;
         int[] allUsers;
@@ -10019,19 +10037,17 @@
         boolean sysPkg = (isSystemApp(oldPackage));
         if (sysPkg) {
             replaceSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
-                    user, allUsers, perUserInstalled, installerPackageName, res,
-                    abiOverride);
+                    user, allUsers, perUserInstalled, installerPackageName, res);
         } else {
             replaceNonSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
-                    user, allUsers, perUserInstalled, installerPackageName, res,
-                    abiOverride);
+                    user, allUsers, perUserInstalled, installerPackageName, res);
         }
     }
 
     private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage,
             PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
             int[] allUsers, boolean[] perUserInstalled,
-            String installerPackageName, PackageInstalledInfo res, String abiOverride) {
+            String installerPackageName, PackageInstalledInfo res) {
         String pkgName = deletedPackage.packageName;
         boolean deletedPkg = true;
         boolean updatedSettings = false;
@@ -10056,7 +10072,7 @@
             deleteCodeCacheDirsLI(pkgName);
             try {
                 final PackageParser.Package newPackage = scanPackageLI(pkg, parseFlags,
-                        scanMode | SCAN_UPDATE_TIME, System.currentTimeMillis(), user, abiOverride);
+                        scanMode | SCAN_UPDATE_TIME, System.currentTimeMillis(), user);
                 updateSettingsLI(newPackage, installerPackageName, allUsers, perUserInstalled, res);
                 updatedSettings = true;
             } catch (PackageManagerException e) {
@@ -10089,8 +10105,7 @@
                 int oldScanMode = (oldOnSd ? 0 : SCAN_MONITOR) | SCAN_UPDATE_SIGNATURE
                         | SCAN_UPDATE_TIME;
                 try {
-                    scanPackageLI(restoreFile, oldParseFlags, oldScanMode, origUpdateTime, null,
-                            null);
+                    scanPackageLI(restoreFile, oldParseFlags, oldScanMode, origUpdateTime, null);
                 } catch (PackageManagerException e) {
                     Slog.e(TAG, "Failed to restore package : " + pkgName + " after failed upgrade: "
                             + e.getMessage());
@@ -10112,7 +10127,7 @@
     private void replaceSystemPackageLI(PackageParser.Package deletedPackage,
             PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
             int[] allUsers, boolean[] perUserInstalled,
-            String installerPackageName, PackageInstalledInfo res, String abiOverride) {
+            String installerPackageName, PackageInstalledInfo res) {
         if (DEBUG_INSTALL) Slog.d(TAG, "replaceSystemPackageLI: new=" + pkg
                 + ", old=" + deletedPackage);
         boolean updatedSettings = false;
@@ -10172,7 +10187,7 @@
 
         PackageParser.Package newPackage = null;
         try {
-            newPackage = scanPackageLI(pkg, parseFlags, scanMode, 0, user, abiOverride);
+            newPackage = scanPackageLI(pkg, parseFlags, scanMode, 0, user);
             if (newPackage.mExtras != null) {
                 final PackageSetting newPkgSetting = (PackageSetting) newPackage.mExtras;
                 newPkgSetting.firstInstallTime = oldPkgSetting.firstInstallTime;
@@ -10204,8 +10219,7 @@
             }
             // Add back the old system package
             try {
-                scanPackageLI(oldPkg, parseFlags, SCAN_MONITOR | SCAN_UPDATE_SIGNATURE, 0, user,
-                        null);
+                scanPackageLI(oldPkg, parseFlags, SCAN_MONITOR | SCAN_UPDATE_SIGNATURE, 0, user);
             } catch (PackageManagerException e) {
                 Slog.e(TAG, "Failed to restore original package: " + e.getMessage());
             }
@@ -10336,6 +10350,9 @@
             return;
         }
 
+        // Mark that we have an install time CPU ABI override.
+        pkg.cpuAbiOverride = args.abiOverride;
+
         String pkgName = res.name = pkg.packageName;
         if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_TEST_ONLY) != 0) {
             if ((pFlags&PackageManager.INSTALL_ALLOW_TEST) == 0) {
@@ -10454,10 +10471,10 @@
 
         if (replace) {
             replacePackageLI(pkg, parseFlags, scanMode, args.user,
-                    installerPackageName, res, args.abiOverride);
+                    installerPackageName, res);
         } else {
             installNewPackageLI(pkg, parseFlags, scanMode | SCAN_DELETE_DATA_ON_FAILURES, args.user,
-                    installerPackageName, res, args.abiOverride);
+                    installerPackageName, res);
         }
         synchronized (mPackages) {
             final PackageSetting ps = mSettings.mPackages.get(pkgName);
@@ -10893,8 +10910,7 @@
 
         final PackageParser.Package newPkg;
         try {
-            newPkg = scanPackageLI(disabledPs.codePath, parseFlags, SCAN_MONITOR | SCAN_NO_PATHS, 0,
-                    null, null);
+            newPkg = scanPackageLI(disabledPs.codePath, parseFlags, SCAN_MONITOR | SCAN_NO_PATHS, 0, null);
         } catch (PackageManagerException e) {
             Slog.w(TAG, "Failed to restore system package:" + newPs.name + ": " + e.getMessage());
             return false;
@@ -12852,7 +12868,7 @@
                 synchronized (mInstallLock) {
                     PackageParser.Package pkg = null;
                     try {
-                        pkg = scanPackageLI(new File(codePath), parseFlags, 0, 0, null, null);
+                        pkg = scanPackageLI(new File(codePath), parseFlags, 0, 0, null);
                     } catch (PackageManagerException e) {
                         Slog.w(TAG, "Failed to scan " + codePath + ": " + e.getMessage());
                     }
diff --git a/services/core/java/com/android/server/pm/PackageSetting.java b/services/core/java/com/android/server/pm/PackageSetting.java
index a6571cf..696aa34 100644
--- a/services/core/java/com/android/server/pm/PackageSetting.java
+++ b/services/core/java/com/android/server/pm/PackageSetting.java
@@ -31,9 +31,11 @@
 
     PackageSetting(String name, String realName, File codePath, File resourcePath,
             String legacyNativeLibraryPathString, String primaryCpuAbiString,
-            String secondaryCpuAbiString, int pVersionCode, int pkgFlags) {
+            String secondaryCpuAbiString, String cpuAbiOverrideString,
+            int pVersionCode, int pkgFlags) {
         super(name, realName, codePath, resourcePath, legacyNativeLibraryPathString,
-                primaryCpuAbiString, secondaryCpuAbiString, pVersionCode, pkgFlags);
+                primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString,
+                pVersionCode, pkgFlags);
     }
 
     /**
diff --git a/services/core/java/com/android/server/pm/PackageSettingBase.java b/services/core/java/com/android/server/pm/PackageSettingBase.java
index e29332c..bf13fd9 100644
--- a/services/core/java/com/android/server/pm/PackageSettingBase.java
+++ b/services/core/java/com/android/server/pm/PackageSettingBase.java
@@ -64,8 +64,25 @@
     @Deprecated
     String legacyNativeLibraryPathString;
 
+    /**
+     * The primary CPU abi for this package. This value is regenerated at every
+     * boot scan.
+     */
     String primaryCpuAbiString;
+
+    /**
+     * The secondary CPU abi for this package. This value is regenerated at every
+     * boot scan.
+     */
     String secondaryCpuAbiString;
+
+    /**
+     * The install time CPU override, if any. This value is written at install time
+     * and doesn't change during the life of an install. If non-null,
+     * {@code primaryCpuAbiString} will contain the same value.
+     */
+    String cpuAbiOverrideString;
+
     long timeStamp;
     long firstInstallTime;
     long lastUpdateTime;
@@ -94,12 +111,13 @@
     String installerPackageName;
     PackageSettingBase(String name, String realName, File codePath, File resourcePath,
             String legacyNativeLibraryPathString, String primaryCpuAbiString,
-            String secondaryCpuAbiString, int pVersionCode, int pkgFlags) {
+            String secondaryCpuAbiString, String cpuAbiOverrideString,
+            int pVersionCode, int pkgFlags) {
         super(pkgFlags);
         this.name = name;
         this.realName = realName;
         init(codePath, resourcePath, legacyNativeLibraryPathString, primaryCpuAbiString,
-                secondaryCpuAbiString, pVersionCode);
+                secondaryCpuAbiString, cpuAbiOverrideString, pVersionCode);
     }
 
     /**
@@ -118,6 +136,7 @@
         legacyNativeLibraryPathString = base.legacyNativeLibraryPathString;
         primaryCpuAbiString = base.primaryCpuAbiString;
         secondaryCpuAbiString = base.secondaryCpuAbiString;
+        cpuAbiOverrideString = base.cpuAbiOverrideString;
         timeStamp = base.timeStamp;
         firstInstallTime = base.firstInstallTime;
         lastUpdateTime = base.lastUpdateTime;
@@ -145,7 +164,8 @@
     }
 
     void init(File codePath, File resourcePath, String legacyNativeLibraryPathString,
-              String primaryCpuAbiString, String secondaryCpuAbiString, int pVersionCode) {
+              String primaryCpuAbiString, String secondaryCpuAbiString,
+              String cpuAbiOverrideString, int pVersionCode) {
         this.codePath = codePath;
         this.codePathString = codePath.toString();
         this.resourcePath = resourcePath;
@@ -153,6 +173,7 @@
         this.legacyNativeLibraryPathString = legacyNativeLibraryPathString;
         this.primaryCpuAbiString = primaryCpuAbiString;
         this.secondaryCpuAbiString = secondaryCpuAbiString;
+        this.cpuAbiOverrideString = cpuAbiOverrideString;
         this.versionCode = pVersionCode;
     }
 
@@ -185,6 +206,7 @@
 
         primaryCpuAbiString = base.primaryCpuAbiString;
         secondaryCpuAbiString = base.secondaryCpuAbiString;
+        cpuAbiOverrideString = base.cpuAbiOverrideString;
         timeStamp = base.timeStamp;
         firstInstallTime = base.firstInstallTime;
         lastUpdateTime = base.lastUpdateTime;
diff --git a/services/core/java/com/android/server/pm/PendingPackage.java b/services/core/java/com/android/server/pm/PendingPackage.java
index 85be651..5d30e76 100644
--- a/services/core/java/com/android/server/pm/PendingPackage.java
+++ b/services/core/java/com/android/server/pm/PendingPackage.java
@@ -22,10 +22,12 @@
     final int sharedId;
 
     PendingPackage(String name, String realName, File codePath, File resourcePath,
-            String nativeLibrary32PathString, String nativeLibrary64PathString,
-            String requiredCpuAbiString, int sharedId, int pVersionCode, int pkgFlags) {
-        super(name, realName, codePath, resourcePath, nativeLibrary32PathString, nativeLibrary64PathString,
-                requiredCpuAbiString, pVersionCode, pkgFlags);
+            String legacyNativeLibraryPathString, String primaryCpuAbiString,
+            String secondaryCpuAbiString, String cpuAbiOverrideString, int sharedId,
+            int pVersionCode, int pkgFlags) {
+        super(name, realName, codePath, resourcePath, legacyNativeLibraryPathString,
+                primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString,
+                pVersionCode, pkgFlags);
         this.sharedId = sharedId;
     }
 }
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index cd2aa22..c346f71 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -325,8 +325,8 @@
 
     PackageSetting getPackageLPw(PackageParser.Package pkg, PackageSetting origPackage,
             String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
-            String legacyNativeLibraryPathString, String primaryCpuAbi, String secondaryCpuAbi, int pkgFlags,
-            UserHandle user, boolean add) {
+            String legacyNativeLibraryPathString, String primaryCpuAbi, String secondaryCpuAbi,
+            int pkgFlags, UserHandle user, boolean add) {
         final String name = pkg.packageName;
         PackageSetting p = getPackageLPw(name, origPackage, realName, sharedUser, codePath,
                 resourcePath, legacyNativeLibraryPathString, primaryCpuAbi, secondaryCpuAbi,
@@ -417,7 +417,8 @@
         }
         PackageSetting ret = addPackageLPw(name, p.realName, p.codePath, p.resourcePath,
                 p.legacyNativeLibraryPathString, p.primaryCpuAbiString,
-                p.secondaryCpuAbiString, p.appId, p.versionCode, p.pkgFlags);
+                p.secondaryCpuAbiString, p.secondaryCpuAbiString,
+                p.appId, p.versionCode, p.pkgFlags);
         mDisabledSysPackages.remove(name);
         return ret;
     }
@@ -432,7 +433,7 @@
 
     PackageSetting addPackageLPw(String name, String realName, File codePath, File resourcePath,
             String legacyNativeLibraryPathString, String primaryCpuAbiString, String secondaryCpuAbiString,
-            int uid, int vc, int pkgFlags) {
+            String cpuAbiOverrideString, int uid, int vc, int pkgFlags) {
         PackageSetting p = mPackages.get(name);
         if (p != null) {
             if (p.appId == uid) {
@@ -443,7 +444,8 @@
             return null;
         }
         p = new PackageSetting(name, realName, codePath, resourcePath,
-                legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString, vc, pkgFlags);
+                legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString,
+                cpuAbiOverrideString, vc, pkgFlags);
         p.appId = uid;
         if (addUserIdLPw(uid, p, name)) {
             mPackages.put(name, p);
@@ -512,11 +514,13 @@
     private PackageSetting getPackageLPw(String name, PackageSetting origPackage,
             String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
             String legacyNativeLibraryPathString, String primaryCpuAbiString, String secondaryCpuAbiString,
-            int vc, int pkgFlags, UserHandle installUser, boolean add, boolean allowInstall) {
+            int vc, int pkgFlags, UserHandle installUser, boolean add,
+            boolean allowInstall) {
         PackageSetting p = mPackages.get(name);
         if (p != null) {
             p.primaryCpuAbiString = primaryCpuAbiString;
             p.secondaryCpuAbiString = secondaryCpuAbiString;
+
             if (!p.codePath.equals(codePath)) {
                 // Check to see if its a disabled system app
                 if ((p.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
@@ -560,7 +564,8 @@
             if (origPackage != null) {
                 // We are consuming the data from an existing package.
                 p = new PackageSetting(origPackage.name, name, codePath, resourcePath,
-                        legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString, vc, pkgFlags);
+                        legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString,
+                        null /* cpuAbiOverrideString */, vc, pkgFlags);
                 if (PackageManagerService.DEBUG_UPGRADE) Log.v(PackageManagerService.TAG, "Package "
                         + name + " is adopting original package " + origPackage.name);
                 // Note that we will retain the new package's signature so
@@ -577,7 +582,8 @@
                 p.setTimeStamp(codePath.lastModified());
             } else {
                 p = new PackageSetting(name, realName, codePath, resourcePath,
-                        legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString, vc, pkgFlags);
+                        legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString,
+                        null /* cpuAbiOverrideString */, vc, pkgFlags);
                 p.setTimeStamp(codePath.lastModified());
                 p.sharedUser = sharedUser;
                 // If this is not a system app, it starts out stopped.
@@ -720,6 +726,7 @@
         // Update the required Cpu Abi
         p.primaryCpuAbiString = pkg.applicationInfo.primaryCpuAbi;
         p.secondaryCpuAbiString = pkg.applicationInfo.secondaryCpuAbi;
+        p.cpuAbiOverrideString = pkg.cpuAbiOverride;
         // Update version code if needed
         if (pkg.mVersionCode != p.versionCode) {
             p.versionCode = pkg.mVersionCode;
@@ -1888,6 +1895,9 @@
         if (pkg.secondaryCpuAbiString != null) {
             serializer.attribute(null, "secondaryCpuAbi", pkg.secondaryCpuAbiString);
         }
+        if (pkg.cpuAbiOverrideString != null) {
+            serializer.attribute(null, "cpuAbiOverride", pkg.cpuAbiOverrideString);
+        }
 
         if (pkg.sharedUser == null) {
             serializer.attribute(null, "userId", Integer.toString(pkg.appId));
@@ -1938,6 +1948,9 @@
         if (pkg.secondaryCpuAbiString != null) {
             serializer.attribute(null, "secondaryCpuAbi", pkg.secondaryCpuAbiString);
         }
+        if (pkg.cpuAbiOverrideString != null) {
+            serializer.attribute(null, "cpuAbiOverride", pkg.cpuAbiOverrideString);
+        }
 
         serializer.attribute(null, "flags", Integer.toString(pkg.pkgFlags));
         serializer.attribute(null, "ft", Long.toHexString(pkg.timeStamp));
@@ -2248,8 +2261,8 @@
                 PackageSetting p = getPackageLPw(pp.name, null, pp.realName,
                         (SharedUserSetting) idObj, pp.codePath, pp.resourcePath,
                         pp.legacyNativeLibraryPathString, pp.primaryCpuAbiString,
-                        pp.secondaryCpuAbiString, pp.versionCode, pp.pkgFlags,
-                        null, true /* add */, false /* allowInstall */);
+                        pp.secondaryCpuAbiString, pp.versionCode, pp.pkgFlags, null,
+                        true /* add */, false /* allowInstall */);
                 if (p == null) {
                     PackageManagerService.reportSettingsProblem(Log.WARN,
                             "Unable to create application package for " + pp.name);
@@ -2673,6 +2686,7 @@
 
         String primaryCpuAbiStr = parser.getAttributeValue(null, "primaryCpuAbi");
         String secondaryCpuAbiStr = parser.getAttributeValue(null, "secondaryCpuAbi");
+        String cpuAbiOverrideStr = parser.getAttributeValue(null, "cpuAbiOverride");
 
         if (primaryCpuAbiStr == null && legacyCpuAbiStr != null) {
             primaryCpuAbiStr = legacyCpuAbiStr;
@@ -2698,7 +2712,7 @@
         }
         PackageSetting ps = new PackageSetting(name, realName, codePathFile,
                 new File(resourcePathStr), legacyNativeLibraryPathStr, primaryCpuAbiStr,
-                secondaryCpuAbiStr, versionCode, pkgFlags);
+                secondaryCpuAbiStr, cpuAbiOverrideStr, versionCode, pkgFlags);
         String timeStampStr = parser.getAttributeValue(null, "ft");
         if (timeStampStr != null) {
             try {
@@ -2768,6 +2782,7 @@
         String legacyNativeLibraryPathStr = null;
         String primaryCpuAbiString = null;
         String secondaryCpuAbiString = null;
+        String cpuAbiOverrideString = null;
         String systemStr = null;
         String installerPackageName = null;
         String uidError = null;
@@ -2792,6 +2807,7 @@
             legacyNativeLibraryPathStr = parser.getAttributeValue(null, "nativeLibraryPath");
             primaryCpuAbiString = parser.getAttributeValue(null, "primaryCpuAbi");
             secondaryCpuAbiString = parser.getAttributeValue(null, "secondaryCpuAbi");
+            cpuAbiOverrideString = parser.getAttributeValue(null, "cpuAbiOverride");
 
             if (primaryCpuAbiString == null && legacyCpuAbiString != null) {
                 primaryCpuAbiString = legacyCpuAbiString;
@@ -2874,7 +2890,7 @@
             } else if (userId > 0) {
                 packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr),
                         new File(resourcePathStr), legacyNativeLibraryPathStr, primaryCpuAbiString,
-                        secondaryCpuAbiString, userId, versionCode, pkgFlags);
+                        secondaryCpuAbiString, cpuAbiOverrideString, userId, versionCode, pkgFlags);
                 if (PackageManagerService.DEBUG_SETTINGS)
                     Log.i(PackageManagerService.TAG, "Reading package " + name + ": userId="
                             + userId + " pkg=" + packageSetting);
@@ -2892,7 +2908,8 @@
                 if (userId > 0) {
                     packageSetting = new PendingPackage(name.intern(), realName, new File(
                             codePathStr), new File(resourcePathStr), legacyNativeLibraryPathStr,
-                            primaryCpuAbiString, legacyCpuAbiString, userId, versionCode, pkgFlags);
+                            primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString,
+                            userId, versionCode, pkgFlags);
                     packageSetting.setTimeStamp(timeStamp);
                     packageSetting.firstInstallTime = firstInstallTime;
                     packageSetting.lastUpdateTime = lastUpdateTime;
diff --git a/services/core/java/com/android/server/tv/PersistentDataStore.java b/services/core/java/com/android/server/tv/PersistentDataStore.java
index 852e640..4af8f2c 100644
--- a/services/core/java/com/android/server/tv/PersistentDataStore.java
+++ b/services/core/java/com/android/server/tv/PersistentDataStore.java
@@ -91,6 +91,7 @@
     }
 
     public void setParentalControlsEnabled(boolean enabled) {
+        loadIfNeeded();
         if (mParentalControlsEnabled != enabled) {
             mParentalControlsEnabled = enabled;
             mParentalControlsEnabledChanged = true;
@@ -114,6 +115,7 @@
     }
 
     public void addBlockedRating(TvContentRating rating) {
+        loadIfNeeded();
         if (rating != null && !mBlockedRatings.contains(rating)) {
             mBlockedRatings.add(rating);
             mBlockedRatingsChanged = true;
@@ -122,6 +124,7 @@
     }
 
     public void removeBlockedRating(TvContentRating rating) {
+        loadIfNeeded();
         if (rating != null && mBlockedRatings.contains(rating)) {
             mBlockedRatings.remove(rating);
             mBlockedRatingsChanged = true;
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index dc5bc84..0b39598 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -996,12 +996,13 @@
         }
 
         private void ensureParentalControlsPermission() {
-            if (mContext.checkCallingPermission(
-                    android.Manifest.permission.MODIFY_PARENTAL_CONTROLS)
-                    != PackageManager.PERMISSION_GRANTED) {
-                throw new SecurityException(
-                        "The caller does not have parental controls permission");
-            }
+            // STOPSHIP: Uncomment when b/16984416 is resolved.
+            //if (mContext.checkCallingPermission(
+            //        android.Manifest.permission.MODIFY_PARENTAL_CONTROLS)
+            //        != PackageManager.PERMISSION_GRANTED) {
+            //    throw new SecurityException(
+            //            "The caller does not have parental controls permission");
+            //}
         }
 
         @Override
@@ -1808,7 +1809,7 @@
                 // If there are any other sessions based on this session, they should be released.
                 UserState userState = getUserStateLocked(mUserId);
                 for (SessionState sessionState : userState.sessionStateMap.values()) {
-                    if (mSession != null && mSession == sessionState.mHardwareSessionToken) {
+                    if (mSessionToken == sessionState.mHardwareSessionToken) {
                         try {
                             sessionState.mSession.release();
                         } catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index e7ebae7..26dc448 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -462,6 +462,9 @@
     int mRotation = 0;
     int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
     boolean mAltOrientation = false;
+
+    private boolean mKeyguardWaitingForActivityDrawn;
+
     class RotationWatcher {
         IRotationWatcher watcher;
         IBinder.DeathRecipient deathRecipient;
@@ -5247,6 +5250,20 @@
         }
     }
 
+    public void keyguardWaitingForActivityDrawn() {
+        synchronized (mWindowMap) {
+            mKeyguardWaitingForActivityDrawn = true;
+        }
+    }
+
+    public void notifyActivityDrawnForKeyguard() {
+        synchronized (mWindowMap) {
+            if (mKeyguardWaitingForActivityDrawn) {
+                mPolicy.notifyActivityDrawnForKeyguardLw();
+            }
+        }
+    }
+
     void showGlobalActions() {
         mPolicy.showGlobalActions();
     }