Merge "Add the capture session (and its availability) in the EventPayload" into lmp-dev
diff --git a/Android.mk b/Android.mk
index 5485e9f..cd2cebb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -368,6 +368,8 @@
 	telephony/java/com/android/ims/internal/IImsStreamMediaSession.aidl \
 	telephony/java/com/android/ims/internal/IImsUt.aidl \
 	telephony/java/com/android/ims/internal/IImsUtListener.aidl \
+	telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl \
+	telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl \
 	telephony/java/com/android/ims/ImsConfigListener.aidl \
 	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
 	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
diff --git a/api/current.txt b/api/current.txt
index c6f6256..75d6e57 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 = 16843919; // 0x101048f
+    field public static final int actionBarPopupTheme = 16843917; // 0x101048d
     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 = 16843827; // 0x1010433
+    field public static final int actionBarTheme = 16843825; // 0x1010431
     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 = 16843900; // 0x101047c
+    field public static final int actionModeFindDrawable = 16843898; // 0x101047a
     field public static final int actionModePasteDrawable = 16843539; // 0x1010313
     field public static final int actionModeSelectAllDrawable = 16843646; // 0x101037e
-    field public static final int actionModeShareDrawable = 16843899; // 0x101047b
+    field public static final int actionModeShareDrawable = 16843897; // 0x1010479
     field public static final int actionModeSplitBackground = 16843677; // 0x101039d
     field public static final int actionModeStyle = 16843668; // 0x1010394
-    field public static final int actionModeWebSearchDrawable = 16843901; // 0x101047d
+    field public static final int actionModeWebSearchDrawable = 16843899; // 0x101047b
     field public static final int actionOverflowButtonStyle = 16843510; // 0x10102f6
-    field public static final int actionOverflowMenuStyle = 16843846; // 0x1010446
+    field public static final int actionOverflowMenuStyle = 16843844; // 0x1010444
     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 = 16843944; // 0x10104a8
-    field public static final int amPmTextColor = 16843943; // 0x10104a7
+    field public static final int amPmBackgroundColor = 16843942; // 0x10104a6
+    field public static final int amPmTextColor = 16843941; // 0x10104a5
     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 = 16843849; // 0x1010449
+    field public static final int autoRemoveFromRecents = 16843847; // 0x1010447
     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 = 16843885; // 0x101046d
-    field public static final int backgroundTintMode = 16843886; // 0x101046e
+    field public static final int backgroundTint = 16843883; // 0x101046b
+    field public static final int backgroundTintMode = 16843884; // 0x101046c
     field public static final int backupAgent = 16843391; // 0x101027f
     field public static final int 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 = 16843917; // 0x101048d
-    field public static final int buttonBarNeutralButtonStyle = 16843916; // 0x101048c
-    field public static final int buttonBarPositiveButtonStyle = 16843915; // 0x101048b
+    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 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 = 16843889; // 0x1010471
-    field public static final int buttonTintMode = 16843890; // 0x1010472
+    field public static final int buttonTint = 16843887; // 0x101046f
+    field public static final int buttonTintMode = 16843888; // 0x1010470
     field public static final int cacheColorHint = 16843009; // 0x1010101
-    field public static final int calendarTextColor = 16843933; // 0x101049d
+    field public static final int calendarTextColor = 16843931; // 0x101049b
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
     field public static final int 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 = 16843946; // 0x10104aa
-    field public static final int checkMarkTintMode = 16843947; // 0x10104ab
+    field public static final int checkMarkTint = 16843944; // 0x10104a8
+    field public static final int checkMarkTintMode = 16843945; // 0x10104a9
     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 = 16843907; // 0x1010483
+    field public static final int closeIcon = 16843905; // 0x1010481
     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 = 16843831; // 0x1010437
+    field public static final int colorAccent = 16843829; // 0x1010435
     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 = 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 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 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 = 16843829; // 0x1010435
-    field public static final int colorPrimaryDark = 16843830; // 0x1010436
+    field public static final int colorPrimary = 16843827; // 0x1010433
+    field public static final int colorPrimaryDark = 16843828; // 0x1010434
     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 = 16843911; // 0x1010487
+    field public static final int commitIcon = 16843909; // 0x1010485
     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 = 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 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 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 = 16843951; // 0x10104af
-    field public static final int datePickerMode = 16843958; // 0x10104b6
+    field public static final int datePickerDialogTheme = 16843949; // 0x10104ad
+    field public static final int datePickerMode = 16843956; // 0x10104b4
     field public static final int datePickerStyle = 16843612; // 0x101035c
     field public static final int dateTextAppearance = 16843593; // 0x1010349
-    field public static final int dayOfWeekBackgroundColor = 16843926; // 0x1010496
-    field public static final int dayOfWeekTextAppearance = 16843927; // 0x1010497
+    field public static final int dayOfWeekBackgroundColor = 16843924; // 0x1010494
+    field public static final int dayOfWeekTextAppearance = 16843925; // 0x1010495
     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 = 16843847; // 0x1010447
+    field public static final int documentLaunchMode = 16843845; // 0x1010445
     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 = 16843871; // 0x101045f
-    field public static final int elevation = 16843842; // 0x1010442
+    field public static final int elegantTextHeight = 16843869; // 0x101045d
+    field public static final int elevation = 16843840; // 0x1010440
     field public static final int ellipsize = 16842923; // 0x10100ab
     field public static final int ems = 16843096; // 0x1010158
     field public static final int 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 = 16843844; // 0x1010444
+    field public static final int excludeClass = 16843842; // 0x1010442
     field public static final int excludeFromRecents = 16842775; // 0x1010017
-    field public static final int excludeId = 16843843; // 0x1010443
-    field public static final int excludeName = 16843856; // 0x1010450
+    field public static final int excludeId = 16843841; // 0x1010441
+    field public static final int excludeName = 16843854; // 0x101044e
     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 = 16843807; // 0x101041f
+    field public static final int fillColor = 16843806; // 0x101041e
     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 = 16843962; // 0x10104ba
+    field public static final int fontFeatureSettings = 16843960; // 0x10104b8
     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 = 16843887; // 0x101046f
-    field public static final int foregroundTintMode = 16843888; // 0x1010470
+    field public static final int foregroundTint = 16843885; // 0x101046d
+    field public static final int foregroundTintMode = 16843886; // 0x101046e
     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 = 16843852; // 0x101044c
+    field public static final int fromId = 16843850; // 0x101044a
     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 = 16843893; // 0x1010475
+    field public static final int fullBackupOnly = 16843891; // 0x1010473
     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 = 16843908; // 0x1010484
+    field public static final int goIcon = 16843906; // 0x1010482
     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 = 16843938; // 0x10104a2
+    field public static final int headerAmPmTextAppearance = 16843936; // 0x10104a0
     field public static final int headerBackground = 16843055; // 0x101012f
-    field public static final int headerBackgroundColor = 16843939; // 0x10104a3
-    field public static final int headerDayOfMonthTextAppearance = 16843929; // 0x1010499
+    field public static final int headerBackgroundColor = 16843937; // 0x10104a1
+    field public static final int headerDayOfMonthTextAppearance = 16843927; // 0x1010497
     field public static final int headerDividersEnabled = 16843310; // 0x101022e
-    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 headerMonthTextAppearance = 16843926; // 0x1010496
+    field public static final int headerTimeTextAppearance = 16843935; // 0x101049f
+    field public static final int headerYearTextAppearance = 16843928; // 0x1010498
     field public static final int height = 16843093; // 0x1010155
-    field public static final int hideOnContentScroll = 16843845; // 0x1010445
+    field public static final int hideOnContentScroll = 16843843; // 0x1010443
     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 = 16843883; // 0x101046b
-    field public static final int indeterminateTintMode = 16843884; // 0x101046c
+    field public static final int indeterminateTint = 16843881; // 0x1010469
+    field public static final int indeterminateTintMode = 16843882; // 0x101046a
     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 = 16843960; // 0x10104b8
+    field public static final int inset = 16843958; // 0x10104b6
     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 = 16843923; // 0x1010493
-    field public static final int launchTaskBehindSourceAnimation = 16843924; // 0x1010494
+    field public static final int launchTaskBehindBackgroundAnimation = 16843921; // 0x1010491
+    field public static final int launchTaskBehindSourceAnimation = 16843922; // 0x1010492
     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 = 16843867; // 0x101045b
+    field public static final int layout_columnWeight = 16843865; // 0x1010459
     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 = 16843866; // 0x101045a
+    field public static final int layout_rowWeight = 16843864; // 0x1010458
     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 = 16843961; // 0x10104b9
+    field public static final int letterSpacing = 16843959; // 0x10104b7
     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 = 16843857; // 0x1010451
+    field public static final int matchOrder = 16843855; // 0x101044f
     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 = 16843848; // 0x1010448
+    field public static final int maxRecents = 16843846; // 0x1010446
     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 = 16843905; // 0x1010481
+    field public static final int maximumAngle = 16843903; // 0x101047f
     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 = 16843903; // 0x101047f
-    field public static final int minimumVerticalAngle = 16843904; // 0x1010480
+    field public static final int minimumHorizontalAngle = 16843901; // 0x101047d
+    field public static final int minimumVerticalAngle = 16843902; // 0x101047e
     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 = 16843920; // 0x1010490
+    field public static final int multiArch = 16843918; // 0x101048e
     field public static final int multiprocess = 16842771; // 0x1010013
     field public static final int name = 16842755; // 0x1010003
-    field public static final int navigationBarColor = 16843860; // 0x1010454
+    field public static final int navigationBarColor = 16843858; // 0x1010452
     field public static final int navigationMode = 16843471; // 0x10102cf
     field public static final int negativeButtonText = 16843254; // 0x10101f6
-    field public static final int nestedScrollingEnabled = 16843832; // 0x1010438
+    field public static final int nestedScrollingEnabled = 16843830; // 0x1010436
     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 = 16843941; // 0x10104a5
-    field public static final int numbersSelectorColor = 16843942; // 0x10104a6
-    field public static final int numbersTextColor = 16843940; // 0x10104a4
+    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 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 = 16843876; // 0x1010464
+    field public static final int overlapAnchor = 16843874; // 0x1010462
     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 = 16843865; // 0x1010459
+    field public static final int paddingMode = 16843863; // 0x1010457
     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 = 16843808; // 0x1010420
+    field public static final int pathData = 16843807; // 0x101041f
     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 = 16843823; // 0x101042f
+    field public static final int persistableMode = 16843821; // 0x101042d
     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 = 16843918; // 0x101048e
+    field public static final int popupElevation = 16843916; // 0x101048c
     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 = 16843948; // 0x10104ac
+    field public static final int popupTheme = 16843946; // 0x10104aa
     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 = 16843879; // 0x1010467
-    field public static final int progressBackgroundTintMode = 16843880; // 0x1010468
+    field public static final int progressBackgroundTint = 16843877; // 0x1010465
+    field public static final int progressBackgroundTintMode = 16843878; // 0x1010466
     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 = 16843877; // 0x1010465
-    field public static final int progressTintMode = 16843878; // 0x1010466
+    field public static final int progressTint = 16843875; // 0x1010463
+    field public static final int progressTintMode = 16843876; // 0x1010464
     field public static final int prompt = 16843131; // 0x101017b
     field public static final int propertyName = 16843489; // 0x10102e1
-    field public static final int propertyXName = 16843894; // 0x1010476
-    field public static final int propertyYName = 16843895; // 0x1010477
+    field public static final int propertyXName = 16843892; // 0x1010474
+    field public static final int propertyYName = 16843893; // 0x1010475
     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 = 16843913; // 0x1010489
+    field public static final int queryBackground = 16843911; // 0x1010487
     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 = 16843934; // 0x101049e
-    field public static final int relinquishTaskIdentity = 16843896; // 0x1010478
+    field public static final int recognitionService = 16843932; // 0x101049c
+    field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
     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 = 16843818; // 0x101042a
+    field public static final int requiredForProfile = 16843816; // 0x1010428
     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 = 16843925; // 0x1010495
-    field public static final int reversible = 16843853; // 0x101044d
+    field public static final int restrictionType = 16843923; // 0x1010493
+    field public static final int reversible = 16843851; // 0x101044b
     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 = 16843909; // 0x1010485
+    field public static final int searchIcon = 16843907; // 0x1010483
     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 = 16843906; // 0x1010482
+    field public static final int searchViewStyle = 16843904; // 0x1010480
     field public static final int secondaryProgress = 16843064; // 0x1010138
-    field public static final int secondaryProgressTint = 16843881; // 0x1010469
-    field public static final int secondaryProgressTintMode = 16843882; // 0x101046a
+    field public static final int secondaryProgressTint = 16843879; // 0x1010467
+    field public static final int secondaryProgressTintMode = 16843880; // 0x1010468
     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 = 16843870; // 0x101045e
+    field public static final int selectableItemBackgroundBorderless = 16843868; // 0x101045c
     field public static final int selectedDateVerticalBar = 16843591; // 0x1010347
     field public static final int selectedWeekBackgroundColor = 16843586; // 0x1010342
-    field public static final int sessionService = 16843839; // 0x101043f
+    field public static final int sessionService = 16843837; // 0x101043d
     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 = 16843952; // 0x10104b0
+    field public static final int showText = 16843950; // 0x10104ae
     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 = 16843826; // 0x1010432
+    field public static final int slideEdge = 16843824; // 0x1010430
     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 = 16843854; // 0x101044e
+    field public static final int splitTrack = 16843852; // 0x101044c
     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 = 16843840; // 0x1010440
+    field public static final int stackViewStyle = 16843838; // 0x101043e
     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 = 16843850; // 0x101044a
+    field public static final int stateListAnimator = 16843848; // 0x1010448
     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 = 16843859; // 0x1010453
+    field public static final int statusBarColor = 16843857; // 0x1010451
     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 = 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 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 subtitle = 16843473; // 0x10102d1
-    field public static final int subtitleTextAppearance = 16843825; // 0x1010431
+    field public static final int subtitleTextAppearance = 16843823; // 0x101042f
     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 = 16843912; // 0x1010488
+    field public static final int suggestionRowLayout = 16843910; // 0x1010486
     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 = 16843841; // 0x1010441
+    field public static final int switchStyle = 16843839; // 0x101043f
     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 = 16843855; // 0x101044f
+    field public static final int targetName = 16843853; // 0x101044d
     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 = 16843828; // 0x1010434
+    field public static final int textAppearanceListItemSecondary = 16843826; // 0x1010432
     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 = 16843891; // 0x1010473
-    field public static final int thumbTintMode = 16843892; // 0x1010474
+    field public static final int thumbTint = 16843889; // 0x1010471
+    field public static final int thumbTintMode = 16843890; // 0x1010472
     field public static final int thumbnail = 16843429; // 0x10102a5
     field public static final int tileMode = 16843265; // 0x1010201
-    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 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 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 = 16843824; // 0x1010430
+    field public static final int titleTextAppearance = 16843822; // 0x101042e
     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 = 16843851; // 0x101044b
+    field public static final int toId = 16843849; // 0x1010449
     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 = 16843949; // 0x10104ad
+    field public static final int toolbarStyle = 16843947; // 0x10104ab
     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 = 16843921; // 0x1010491
+    field public static final int touchscreenBlocksFocus = 16843919; // 0x101048f
     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 = 16843868; // 0x101045c
-    field public static final int translateY = 16843869; // 0x101045d
+    field public static final int translateX = 16843866; // 0x101045a
+    field public static final int translateY = 16843867; // 0x101045b
     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 = 16843813; // 0x1010425
-    field public static final int trimPathOffset = 16843814; // 0x1010426
-    field public static final int trimPathStart = 16843812; // 0x1010424
+    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 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 = 16843902; // 0x101047e
+    field public static final int visibilityMode = 16843900; // 0x101047c
     field public static final int visible = 16843156; // 0x1010194
     field public static final int vmSafeMode = 16843448; // 0x10102b8
-    field public static final int voiceIcon = 16843910; // 0x1010486
+    field public static final int voiceIcon = 16843908; // 0x1010484
     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 = 16843838; // 0x101043e
-    field public static final int windowAllowExitTransitionOverlap = 16843837; // 0x101043d
+    field public static final int windowAllowEnterTransitionOverlap = 16843836; // 0x101043c
+    field public static final int windowAllowExitTransitionOverlap = 16843835; // 0x101043b
     field public static final int windowAnimationStyle = 16842926; // 0x10100ae
     field public static final int windowBackground = 16842836; // 0x1010054
-    field public static final int windowClipToOutline = 16843950; // 0x10104ae
+    field public static final int windowClipToOutline = 16843948; // 0x10104ac
     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 = 16843858; // 0x1010452
-    field public static final int windowElevation = 16843922; // 0x1010492
+    field public static final int windowDrawsSystemBarBackgrounds = 16843856; // 0x1010450
+    field public static final int windowElevation = 16843920; // 0x1010490
     field public static final int windowEnableSplitTouch = 16843543; // 0x1010317
     field public static final int windowEnterAnimation = 16842932; // 0x10100b4
-    field public static final int windowEnterTransition = 16843833; // 0x1010439
+    field public static final int windowEnterTransition = 16843831; // 0x1010437
     field public static final int windowExitAnimation = 16842933; // 0x10100b5
-    field public static final int windowExitTransition = 16843834; // 0x101043a
+    field public static final int windowExitTransition = 16843832; // 0x1010438
     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 = 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 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 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 = 16843875; // 0x1010463
+    field public static final int windowTransitionBackgroundFadeDuration = 16843873; // 0x1010461
     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 = 16843931; // 0x101049b
-    field public static final int yearListSelectorColor = 16843932; // 0x101049c
+    field public static final int yearListItemTextAppearance = 16843929; // 0x1010499
+    field public static final int yearListSelectorColor = 16843930; // 0x101049a
     field public static final int yesNoPreferenceStyle = 16842896; // 0x1010090
     field public static final int zAdjustment = 16843201; // 0x10101c1
   }
@@ -3673,6 +3673,7 @@
     field public int id;
     field public android.content.ComponentName origActivity;
     field public int persistentId;
+    field public android.app.ActivityManager.TaskDescription taskDescription;
   }
 
   public static class ActivityManager.RunningAppProcessInfo implements android.os.Parcelable {
@@ -5747,7 +5748,7 @@
     method protected android.appwidget.AppWidgetHostView onCreateView(android.content.Context, int, android.appwidget.AppWidgetProviderInfo);
     method protected void onProviderChanged(int, android.appwidget.AppWidgetProviderInfo);
     method protected void onProvidersChanged();
-    method public final void startAppWidgetConfigureActivityForResult(android.app.Activity, android.content.Intent, int);
+    method public final void startAppWidgetConfigureActivityForResult(android.app.Activity, int, int, int, android.os.Bundle);
     method public void startListening();
     method public void stopListening();
   }
@@ -5775,7 +5776,7 @@
     method public android.appwidget.AppWidgetProviderInfo getAppWidgetInfo(int);
     method public android.os.Bundle getAppWidgetOptions(int);
     method public java.util.List<android.appwidget.AppWidgetProviderInfo> getInstalledProviders();
-    method public java.util.List<android.appwidget.AppWidgetProviderInfo> getInstalledProvidersForProfiles(android.os.UserHandle[]);
+    method public java.util.List<android.appwidget.AppWidgetProviderInfo> getInstalledProvidersForProfile(android.os.UserHandle);
     method public static android.appwidget.AppWidgetManager getInstance(android.content.Context);
     method public void notifyAppWidgetViewDataChanged(int[], int);
     method public void notifyAppWidgetViewDataChanged(int, int);
@@ -15150,6 +15151,7 @@
     method public boolean containsKey(java.lang.String);
     method public int describeContents();
     method public android.graphics.Bitmap getBitmap(java.lang.String);
+    method public android.media.MediaMetadata.Description getDescription();
     method public long getLong(java.lang.String);
     method public android.media.Rating getRating(java.lang.String);
     method public java.lang.String getString(java.lang.String);
@@ -15197,6 +15199,14 @@
     method public android.media.MediaMetadata.Builder putText(java.lang.String, java.lang.CharSequence);
   }
 
+  public final class MediaMetadata.Description {
+    method public java.lang.CharSequence getDescription();
+    method public android.graphics.Bitmap getIcon();
+    method public android.net.Uri getIconUri();
+    method public java.lang.CharSequence getSubtitle();
+    method public java.lang.CharSequence getTitle();
+  }
+
   public abstract deprecated class MediaMetadataEditor {
     method public synchronized void addEditableKey(int);
     method public abstract void apply();
@@ -16734,18 +16744,14 @@
 
   public final class MediaSession {
     ctor public MediaSession(android.content.Context, java.lang.String);
-    method public void addCallback(android.media.session.MediaSession.Callback);
-    method public void addCallback(android.media.session.MediaSession.Callback, android.os.Handler);
-    method public void addTransportControlsCallback(android.media.session.MediaSession.TransportControlsCallback);
-    method public void addTransportControlsCallback(android.media.session.MediaSession.TransportControlsCallback, android.os.Handler);
     method public android.media.session.MediaController getController();
     method public android.media.session.MediaSession.Token getSessionToken();
     method public boolean isActive();
     method public void release();
-    method public void removeCallback(android.media.session.MediaSession.Callback);
-    method public void removeTransportControlsCallback(android.media.session.MediaSession.TransportControlsCallback);
     method public void sendSessionEvent(java.lang.String, android.os.Bundle);
     method public void setActive(boolean);
+    method public void setCallback(android.media.session.MediaSession.Callback);
+    method public void setCallback(android.media.session.MediaSession.Callback, android.os.Handler);
     method public void setExtras(android.os.Bundle);
     method public void setFlags(int);
     method public void setLaunchActivity(android.app.PendingIntent);
@@ -16766,7 +16772,20 @@
   public static abstract class MediaSession.Callback {
     ctor public MediaSession.Callback();
     method public void onCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
-    method public void onMediaButtonEvent(android.content.Intent);
+    method public void onCustomAction(java.lang.String, android.os.Bundle);
+    method public void onFastForward();
+    method public boolean onMediaButtonEvent(android.content.Intent);
+    method public void onPause();
+    method public void onPlay();
+    method public void onPlayFromSearch(java.lang.String, android.os.Bundle);
+    method public void onPlayUri(android.net.Uri, android.os.Bundle);
+    method public void onRewind();
+    method public void onSeekTo(long);
+    method public void onSetRating(android.media.Rating);
+    method public void onSkipToNext();
+    method public void onSkipToPrevious();
+    method public void onSkipToTrack(long);
+    method public void onStop();
   }
 
   public static final class MediaSession.Token implements android.os.Parcelable {
@@ -16792,23 +16811,6 @@
     method public android.media.session.MediaSession.Track.Builder setExtras(android.os.Bundle);
   }
 
-  public static abstract class MediaSession.TransportControlsCallback {
-    ctor public MediaSession.TransportControlsCallback();
-    method public void onCustomAction(java.lang.String, android.os.Bundle);
-    method public void onFastForward();
-    method public void onPause();
-    method public void onPlay();
-    method public void onPlayFromSearch(java.lang.String, android.os.Bundle);
-    method public void onPlayUri(android.net.Uri, android.os.Bundle);
-    method public void onRewind();
-    method public void onSeekTo(long);
-    method public void onSetRating(android.media.Rating);
-    method public void onSkipToNext();
-    method public void onSkipToPrevious();
-    method public void onSkipToTrack(long);
-    method public void onStop();
-  }
-
   public final class MediaSessionManager {
     method public void addActiveSessionsListener(android.media.session.MediaSessionManager.SessionListener, android.content.ComponentName);
     method public java.util.List<android.media.session.MediaController> getActiveSessions(android.content.ComponentName);
@@ -27449,19 +27451,23 @@
     method public final void cancelNotification(java.lang.String);
     method public final void cancelNotifications(java.lang.String[]);
     method public android.service.notification.StatusBarNotification[] getActiveNotifications();
-    method public final int getCurrentListenerFlags();
+    method public final int getCurrentListenerHints();
     method public android.service.notification.NotificationListenerService.RankingMap getCurrentRanking();
     method public android.os.IBinder onBind(android.content.Intent);
     method public void onListenerConnected();
-    method public void onListenerFlagsChanged(int);
+    method public void onListenerHintsChanged(int);
     method public void onNotificationPosted(android.service.notification.StatusBarNotification);
     method public void onNotificationPosted(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
     method public void onNotificationRankingUpdate(android.service.notification.NotificationListenerService.RankingMap);
     method public void onNotificationRemoved(android.service.notification.StatusBarNotification);
     method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
-    method public final void requestListenerFlags(int);
-    field public static final int FLAG_DISABLE_HOST_ALERTS = 1; // 0x1
-    field public static final int FLAG_NONE = 0; // 0x0
+    method public final void requestListenerHints(int);
+    field public static final int HINTS_NONE = 0; // 0x0
+    field public static final int HINT_HOST_DISABLE_EFFECTS = 4; // 0x4
+    field public static final int HINT_HOST_INTERRUPTION_LEVEL_ALL = 1; // 0x1
+    field public static final int HINT_HOST_INTERRUPTION_LEVEL_NONE = 3; // 0x3
+    field public static final int HINT_HOST_INTERRUPTION_LEVEL_PRIORITY = 2; // 0x2
+    field public static final int HOST_INTERRUPTION_LEVEL_MASK = 3; // 0x3
     field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationListenerService";
   }
 
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 3bf8e2e..4b022ff 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -690,8 +690,6 @@
         /**
          * The recent activity values for the highest activity in the stack to have set the values.
          * {@link Activity#setTaskDescription(android.app.ActivityManager.TaskDescription)}.
-         *
-         * @hide
          */
         public TaskDescription taskDescription;
 
diff --git a/core/java/android/app/ActivityTransitionState.java b/core/java/android/app/ActivityTransitionState.java
index 4f556a8..4f3b02c 100644
--- a/core/java/android/app/ActivityTransitionState.java
+++ b/core/java/android/app/ActivityTransitionState.java
@@ -193,7 +193,8 @@
     private void startEnter() {
         if (mEnterActivityOptions.isReturning()) {
             if (mExitingToView != null) {
-                mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom, mExitingToView);
+                mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom, mExitingTo,
+                        mExitingToView);
             } else {
                 mEnterTransitionCoordinator.namedViewsReady(mExitingFrom, mExitingTo);
             }
@@ -248,8 +249,6 @@
                     mEnterTransitionCoordinator.cancelEnter();
                     mEnterTransitionCoordinator = null;
                 }
-                ArrayMap<String, View> sharedElements = new ArrayMap<String, View>();
-                activity.getWindow().getDecorView().findNamedViews(sharedElements);
 
                 ExitTransitionCoordinator exitCoordinator =
                         new ExitTransitionCoordinator(activity, mEnteringNames, null, null, true);
diff --git a/core/java/android/app/EnterTransitionCoordinator.java b/core/java/android/app/EnterTransitionCoordinator.java
index b5d362d..3f1eee1 100644
--- a/core/java/android/app/EnterTransitionCoordinator.java
+++ b/core/java/android/app/EnterTransitionCoordinator.java
@@ -24,6 +24,7 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.ResultReceiver;
+import android.text.TextUtils;
 import android.transition.Transition;
 import android.transition.TransitionManager;
 import android.util.ArrayMap;
@@ -82,8 +83,22 @@
                 });
     }
 
-    public void viewInstancesReady(ArrayList<String> accepted, ArrayList<View> localViews) {
-        triggerViewsReady(mapSharedElements(accepted, localViews));
+    public void viewInstancesReady(ArrayList<String> accepted, ArrayList<String> localNames,
+            ArrayList<View> localViews) {
+        boolean remap = false;
+        for (int i = 0; i < localViews.size(); i++) {
+            View view = localViews.get(i);
+            if (!TextUtils.equals(view.getTransitionName(), localNames.get(i))
+                    || !view.isAttachedToWindow()) {
+                remap = true;
+                break;
+            }
+        }
+        if (remap) {
+            triggerViewsReady(mapNamedElements(accepted, localNames));
+        } else {
+            triggerViewsReady(mapSharedElements(accepted, localViews));
+        }
     }
 
     public void namedViewsReady(ArrayList<String> accepted, ArrayList<String> localNames) {
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 113c533..4b65934 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -59,8 +59,8 @@
     void cancelNotificationsFromListener(in INotificationListener token, in String[] keys);
 
     ParceledListSlice getActiveNotificationsFromListener(in INotificationListener token);
-    void requestFlagsFromListener(in INotificationListener token, int flags);
-    int getFlagsFromListener(in INotificationListener token);
+    void requestHintsFromListener(in INotificationListener token, int hints);
+    int getHintsFromListener(in INotificationListener token);
 
     ZenModeConfig getZenModeConfig();
     boolean setZenModeConfig(in ZenModeConfig config);
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 66a6eb6..69716e5 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -19,12 +19,15 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 
+import android.annotation.NonNull;
+import android.annotation.Nullable;
 import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentSender;
 import android.os.Binder;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
@@ -199,32 +202,30 @@
     /**
      * Starts an app widget provider configure activity for result on behalf of the caller.
      * Use this method if the provider is in another profile as you are not allowed to start
-     * an activity in another profile. The provided intent must have action {@link
-     * AppWidgetManager#ACTION_APPWIDGET_CONFIGURE}. The widget id must be specified by
-     * the {@link AppWidgetManager#EXTRA_APPWIDGET_ID} extra. The provider configure
-     * activity must be specified as the component name of the intent via {@link
-     * Intent#setComponent(android.content.ComponentName)}. The user profile under which
-     * the provider operates is specified via the {@link
-     * AppWidgetManager#EXTRA_APPWIDGET_PROVIDER_PROFILE} extra. If a user profile is
-     * not provided, the current user is used. Finally, you can optionally provide a
-     * request code that is returned in {@link Activity#onActivityResult(int, int,
-     * android.content.Intent)}.
+     * an activity in another profile. You can optionally provide a request code that is
+     * returned in {@link Activity#onActivityResult(int, int, android.content.Intent)} and
+     * an options bundle to be passed to the started activity.
+     * <p>
+     * Note that the provided app widget has to be bound for this method to work.
+     * </p>
      *
      * @param activity The activity from which to start the configure one.
-     * @param intent Properly populated intent for launching the configuration activity.
+     * @param appWidgetId The bound app widget whose provider's config activity to start.
      * @param requestCode Optional request code retuned with the result.
+     * @param intentFlags Optional intent flags.
      *
      * @throws android.content.ActivityNotFoundException If the activity is not found.
      *
      * @see AppWidgetProviderInfo#getProfile()
      */
-    public final void startAppWidgetConfigureActivityForResult(Activity activity, Intent intent,
-            int requestCode) {
+    public final void startAppWidgetConfigureActivityForResult(@NonNull Activity activity,
+            int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) {
         try {
             IntentSender intentSender = sService.createAppWidgetConfigIntentSender(
-                    mContext.getPackageName(), intent);
+                    mContext.getPackageName(), appWidgetId, intentFlags);
             if (intentSender != null) {
-                activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0);
+                activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0,
+                        options);
             } else {
                 throw new ActivityNotFoundException();
             }
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index e5d1d95..086eb7d 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -16,6 +16,7 @@
 
 package android.appwidget;
 
+import android.annotation.Nullable;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -673,24 +674,24 @@
     }
 
     /**
-     * Gets the AppWidget providers for the given user profiles. User profiles can only
+     * Gets the AppWidget providers for the given user profile. User profile can only
      * be the current user or a profile of the current user. For example, the current
      * user may have a corporate profile. In this case the parent user profile has a
      * child profile, the corporate one.
      *
-     * @param profiles The profiles for which to get providers. Passing null is equivaled
+     * @param profile The profile for which to get providers. Passing null is equivaled
      *         to passing only the current user handle.
      * @return The intalled providers.
      *
      * @see android.os.Process#myUserHandle()
      * @see android.os.UserManager#getUserProfiles()
      */
-    public List<AppWidgetProviderInfo> getInstalledProvidersForProfiles(UserHandle[] profiles) {
+    public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(@Nullable UserHandle profile) {
         if (mService == null) {
             return Collections.emptyList();
         }
-        return getInstalledProvidersForProfiles(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
-                profiles);
+        return getInstalledProvidersForProfile(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
+                profile);
     }
 
     /**
@@ -700,7 +701,7 @@
         if (mService == null) {
             return Collections.emptyList();
         }
-        return getInstalledProvidersForProfiles(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
+        return getInstalledProvidersForProfile(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
                 null);
     }
 
@@ -720,18 +721,18 @@
         if (mService == null) {
             return Collections.emptyList();
         }
-        return getInstalledProvidersForProfiles(categoryFilter, null);
+        return getInstalledProvidersForProfile(categoryFilter, null);
     }
 
     /**
-     * Gets the AppWidget providers for the given user profiles. User profiles can only
+     * Gets the AppWidget providers for the given user profile. User profile can only
      * be the current user or a profile of the current user. For example, the current
      * user may have a corporate profile. In this case the parent user profile has a
      * child profile, the corporate one.
      *
      * @param categoryFilter Will only return providers which register as any of the specified
      *        specified categories. See {@link AppWidgetProviderInfo#widgetCategory}.
-     * @param profiles Child profiles of the current user which to be queried. The user
+     * @param profile A profile of the current user which to be queried. The user
      *        is itself also a profile. If null, the providers only for the current user
      *        are returned.
      * @return The intalled providers.
@@ -741,25 +742,19 @@
      *
      * @hide
      */
-    public List<AppWidgetProviderInfo> getInstalledProvidersForProfiles(int categoryFilter,
-            UserHandle[] profiles) {
+    public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter,
+            UserHandle profile) {
         if (mService == null) {
             return Collections.emptyList();
         }
 
-        int[] profileIds = null;
-
-        if (profiles != null) {
-            final int profileCount = profiles.length;
-            profileIds = new int[profileCount];
-            for (int i = 0; i < profileCount; i++) {
-                profileIds[i] = profiles[i].getIdentifier();
-            }
+        if (profile == null) {
+            profile = Process.myUserHandle();
         }
 
         try {
-            List<AppWidgetProviderInfo> providers = mService.getInstalledProviders(categoryFilter,
-                    profileIds);
+            List<AppWidgetProviderInfo> providers = mService.getInstalledProvidersForProfile(
+                    categoryFilter, profile.getIdentifier());
             if (providers == null) {
                 return Collections.emptyList();
             }
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index 6835368..a767246 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -16,6 +16,7 @@
 
 package android.appwidget;
 
+import android.annotation.NonNull;
 import android.content.Context;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
@@ -269,7 +270,7 @@
      *         {@link android.util.DisplayMetrics#densityDpi}.
      * @return The provider icon.
      */
-    public final Drawable loadIcon(Context context, int density) {
+    public final Drawable loadIcon(@NonNull Context context, int density) {
         return loadDrawable(context, density, providerInfo.getIconResource());
     }
 
@@ -289,7 +290,7 @@
      *         {@link android.util.DisplayMetrics#densityDpi}.
      * @return The widget preview image.
      */
-    public final Drawable loadPreviewImage(Context context, int density) {
+    public final Drawable loadPreviewImage(@NonNull Context context, int density) {
         return loadDrawable(context, density, previewImage);
     }
 
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index 5f6fb6e..5b722e2 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -97,6 +97,11 @@
 
     private Context mContext = null;
     private int mMyUid;
+
+    // Since most Providers have only one authority, we keep both a String and a String[] to improve
+    // performance.
+    private String mAuthority;
+    private String[] mAuthorities;
     private String mReadPermission;
     private String mWritePermission;
     private PathPermission[] mPathPermissions;
@@ -193,7 +198,7 @@
         public Cursor query(String callingPkg, Uri uri, String[] projection,
                 String selection, String[] selectionArgs, String sortOrder,
                 ICancellationSignal cancellationSignal) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return rejectQuery(uri, projection, selection, selectionArgs, sortOrder,
@@ -211,14 +216,15 @@
 
         @Override
         public String getType(Uri uri) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             return ContentProvider.this.getType(uri);
         }
 
         @Override
         public Uri insert(String callingPkg, Uri uri, ContentValues initialValues) {
-            int userId = getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
+            int userId = getUserIdFromUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return rejectInsert(uri, initialValues);
@@ -233,7 +239,7 @@
 
         @Override
         public int bulkInsert(String callingPkg, Uri uri, ContentValues[] initialValues) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return 0;
@@ -254,20 +260,22 @@
             final int[] userIds = new int[numOperations];
             for (int i = 0; i < numOperations; i++) {
                 ContentProviderOperation operation = operations.get(i);
-                userIds[i] = getAndEnforceUserId(operation.getUri());
+                Uri uri = operation.getUri();
+                validateIncomingUri(uri);
+                userIds[i] = getUserIdFromUri(uri);
                 if (userIds[i] != UserHandle.USER_CURRENT) {
                     // Removing the user id from the uri.
                     operation = new ContentProviderOperation(operation, true);
                     operations.set(i, operation);
                 }
                 if (operation.isReadOperation()) {
-                    if (enforceReadPermission(callingPkg, operation.getUri())
+                    if (enforceReadPermission(callingPkg, uri)
                             != AppOpsManager.MODE_ALLOWED) {
                         throw new OperationApplicationException("App op not allowed", 0);
                     }
                 }
                 if (operation.isWriteOperation()) {
-                    if (enforceWritePermission(callingPkg, operation.getUri())
+                    if (enforceWritePermission(callingPkg, uri)
                             != AppOpsManager.MODE_ALLOWED) {
                         throw new OperationApplicationException("App op not allowed", 0);
                     }
@@ -290,7 +298,7 @@
 
         @Override
         public int delete(String callingPkg, Uri uri, String selection, String[] selectionArgs) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return 0;
@@ -306,7 +314,7 @@
         @Override
         public int update(String callingPkg, Uri uri, ContentValues values, String selection,
                 String[] selectionArgs) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return 0;
@@ -323,7 +331,7 @@
         public ParcelFileDescriptor openFile(
                 String callingPkg, Uri uri, String mode, ICancellationSignal cancellationSignal)
                 throws FileNotFoundException {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             enforceFilePermission(callingPkg, uri, mode);
             final String original = setCallingPackage(callingPkg);
@@ -339,7 +347,7 @@
         public AssetFileDescriptor openAssetFile(
                 String callingPkg, Uri uri, String mode, ICancellationSignal cancellationSignal)
                 throws FileNotFoundException {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             enforceFilePermission(callingPkg, uri, mode);
             final String original = setCallingPackage(callingPkg);
@@ -363,7 +371,7 @@
 
         @Override
         public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             return ContentProvider.this.getStreamTypes(uri, mimeTypeFilter);
         }
@@ -371,7 +379,7 @@
         @Override
         public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri uri, String mimeType,
                 Bundle opts, ICancellationSignal cancellationSignal) throws FileNotFoundException {
-            getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
             uri = getUriWithoutUserId(uri);
             enforceFilePermission(callingPkg, uri, "r");
             final String original = setCallingPackage(callingPkg);
@@ -390,7 +398,8 @@
 
         @Override
         public Uri canonicalize(String callingPkg, Uri uri) {
-            int userId = getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
+            int userId = getUserIdFromUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return null;
@@ -405,7 +414,8 @@
 
         @Override
         public Uri uncanonicalize(String callingPkg, Uri uri) {
-            int userId = getAndEnforceUserId(uri);
+            validateIncomingUri(uri);
+            int userId = getUserIdFromUri(uri);
             uri = getUriWithoutUserId(uri);
             if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
                 return null;
@@ -620,6 +630,36 @@
     }
 
     /**
+     * Change the authorities of the ContentProvider.
+     * This is normally set for you from its manifest information when the provider is first
+     * created.
+     * @hide
+     * @param authorities the semi-colon separated authorities of the ContentProvider.
+     */
+    protected final void setAuthorities(String authorities) {
+        if (authorities.indexOf(';') == -1) {
+            mAuthority = authorities;
+            mAuthorities = null;
+        } else {
+            mAuthority = null;
+            mAuthorities = authorities.split(";");
+        }
+    }
+
+    /** @hide */
+    protected final boolean matchesOurAuthorities(String authority) {
+        if (mAuthority != null) {
+            return mAuthority.equals(authority);
+        }
+        int length = mAuthorities.length;
+        for (int i = 0; i < length; i++) {
+            if (mAuthorities[i].equals(authority)) return true;
+        }
+        return false;
+    }
+
+
+    /**
      * Change the permission required to read data from the content
      * provider.  This is normally set for you from its manifest information
      * when the provider is first created.
@@ -1634,6 +1674,7 @@
                 setWritePermission(info.writePermission);
                 setPathPermissions(info.pathPermissions);
                 mExported = info.exported;
+                setAuthorities(info.authority);
             }
             ContentProvider.this.onCreate();
         }
@@ -1727,14 +1768,25 @@
     public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
         writer.println("nothing to dump");
     }
+
     /** @hide */
-    private int getAndEnforceUserId(Uri uri) {
-        int userId = getUserIdFromUri(uri, UserHandle.USER_CURRENT);
+    private void validateIncomingUri(Uri uri) throws SecurityException {
+        String auth = uri.getAuthority();
+        int userId = getUserIdFromAuthority(auth, UserHandle.USER_CURRENT);
         if (userId != UserHandle.USER_CURRENT && userId != mContext.getUserId()) {
             throw new SecurityException("trying to query a ContentProvider in user "
-                    + mContext.getUserId() + "with a uri belonging to user " + userId);
+                    + mContext.getUserId() + " with a uri belonging to user " + userId);
         }
-        return userId;
+        if (!matchesOurAuthorities(getAuthorityWithoutUserId(auth))) {
+            String message = "The authority of the uri " + uri + " does not match the one of the "
+                    + "contentProvider: ";
+            if (mAuthority != null) {
+                message += mAuthority;
+            } else {
+                message += mAuthorities;
+            }
+            throw new SecurityException(message);
+        }
     }
 
     /** @hide */
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 87d14b9..0ca800f 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -329,7 +329,7 @@
 
         try {
             String type = ActivityManagerNative.getDefault().getProviderMimeType(
-                    url, UserHandle.myUserId());
+                    ContentProvider.getUriWithoutUserId(url), resolveUserId(url));
             return type;
         } catch (RemoteException e) {
             // Arbitrary and not worth documenting, as Activity
diff --git a/core/java/android/hardware/hdmi/HdmiTvClient.java b/core/java/android/hardware/hdmi/HdmiTvClient.java
index a9040cf..a3f6c00 100644
--- a/core/java/android/hardware/hdmi/HdmiTvClient.java
+++ b/core/java/android/hardware/hdmi/HdmiTvClient.java
@@ -35,55 +35,6 @@
 public final class HdmiTvClient extends HdmiClient {
     private static final String TAG = "HdmiTvClient";
 
-    // Definitions used for setOption(). These should be in sync with the definition
-    // in hardware/libhardware/include/hardware/{hdmi_cec.h,mhl.h}.
-
-    /**
-     * TV gets turned on by incoming &lt;Text/Image View On&gt;. {@code ENABLED} by default.
-     * If set to {@code DISABLED}, TV won't turn on automatically.
-     */
-    public static final int OPTION_CEC_AUTO_WAKEUP = 1;
-
-    /**
-     * If set to {@code DISABLED}, all CEC commands are discarded.
-     *
-     * <p> This option is for internal use only, not supposed to be used by other components.
-     * @hide
-     */
-    public static final int OPTION_CEC_ENABLE = 2;
-
-    /**
-     * If set to {@code DISABLED}, system service yields control of CEC to sub-microcontroller.
-     * If {@code ENABLED}, it take the control back.
-     *
-     * <p> This option is for internal use only, not supposed to be used by other components.
-     * @hide
-     */
-    public static final int OPTION_CEC_SERVICE_CONTROL = 3;
-
-    /**
-     * Put other devices to standby when TV goes to standby. {@code ENABLED} by default.
-     * If set to {@code DISABLED}, TV doesn't send &lt;Standby&gt; to other devices.
-     */
-    public static final int OPTION_CEC_AUTO_DEVICE_OFF = 4;
-
-    /** If set to {@code DISABLED}, TV does not switch ports when mobile device is connected. */
-    public static final int OPTION_MHL_INPUT_SWITCHING = 101;
-
-    /** If set to {@code ENABLED}, TV disables power charging for mobile device. */
-    public static final int OPTION_MHL_POWER_CHARGE = 102;
-
-    /**
-     * If set to {@code DISABLED}, all MHL commands are discarded.
-     *
-     * <p> This option is for internal use only, not supposed to be used by other components.
-     * @hide
-     */
-    public static final int OPTION_MHL_ENABLE = 103;
-
-    public static final int DISABLED = 0;
-    public static final int ENABLED = 1;
-
     HdmiTvClient(IHdmiControlService service) {
         super(service);
     }
diff --git a/core/java/android/hardware/hdmi/IHdmiControlService.aidl b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
index d6cb492..5422bc2 100644
--- a/core/java/android/hardware/hdmi/IHdmiControlService.aidl
+++ b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
@@ -52,9 +52,7 @@
     void setSystemAudioMode(boolean enabled, IHdmiControlCallback callback);
     void addSystemAudioModeChangeListener(IHdmiSystemAudioModeChangeListener listener);
     void removeSystemAudioModeChangeListener(IHdmiSystemAudioModeChangeListener listener);
-    void setControlEnabled(boolean enabled);
     void setArcMode(boolean enabled);
-    void setOption(int option, int value);
     void setProhibitMode(boolean enabled);
     void setSystemAudioVolume(int oldIndex, int newIndex, int maxIndex);
     void setSystemAudioMute(boolean mute);
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 733ab32..23b23af 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4739,6 +4739,23 @@
                 "lock_screen_show_notifications";
 
         /**
+         * List of TV inputs that are currently hidden. This is a string
+         * containing the IDs of all hidden TV inputs. Each ID is separated by ':'.
+         *
+         * @hide
+         */
+        public static final String TV_INPUT_HIDDEN_INPUTS = "tv_input_hidden_inputs";
+
+        /**
+         * List of custom TV input labels. This is a string containing <TV input id, custom name>
+         * pairs. Each pair is separated by ':' and TV input id and custom name are separated by
+         * ','.
+         *
+         * @hide
+         */
+        public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels";
+
+        /**
          * This are the settings to be backed up.
          *
          * NOTE: Settings are backed up and restored in the order they appear
diff --git a/core/java/android/service/notification/INotificationListener.aidl b/core/java/android/service/notification/INotificationListener.aidl
index 19a8ef5..93b2d3b 100644
--- a/core/java/android/service/notification/INotificationListener.aidl
+++ b/core/java/android/service/notification/INotificationListener.aidl
@@ -28,5 +28,5 @@
     void onNotificationRemoved(in StatusBarNotification notification,
             in NotificationRankingUpdate update);
     void onNotificationRankingUpdate(in NotificationRankingUpdate update);
-    void onListenerFlagsChanged(int flags);
+    void onListenerHintsChanged(int hints);
 }
\ No newline at end of file
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index f807ad6..119f7f6 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -58,11 +58,26 @@
     private final String TAG = NotificationListenerService.class.getSimpleName()
             + "[" + getClass().getSimpleName() + "]";
 
-    /** {@link #getCurrentListenerFlags() Listener flags} constant - default state. **/
-    public static final int FLAG_NONE = 0;
-    /** {@link #getCurrentListenerFlags() Listener flags} constant - the primary device UI
-     * should disable notification sound, vibrating and other visual or aural effects. **/
-    public static final int FLAG_DISABLE_HOST_ALERTS = 1;
+    /** {@link #getCurrentListenerHints() Listener hints} constant - default state. */
+    public static final int HINTS_NONE = 0;
+
+    /** Bitmask range for {@link #getCurrentListenerHints() Listener hints} host interruption level
+     * constants.  */
+    public static final int HOST_INTERRUPTION_LEVEL_MASK = 0x3;
+
+    /** {@link #getCurrentListenerHints() Listener hints} constant - Normal interruption level. */
+    public static final int HINT_HOST_INTERRUPTION_LEVEL_ALL = 1;
+
+    /** {@link #getCurrentListenerHints() Listener hints} constant - Priority interruption level. */
+    public static final int HINT_HOST_INTERRUPTION_LEVEL_PRIORITY = 2;
+
+    /** {@link #getCurrentListenerHints() Listener hints} constant - No interruptions level. */
+    public static final int HINT_HOST_INTERRUPTION_LEVEL_NONE = 3;
+
+    /** {@link #getCurrentListenerHints() Listener hints} constant - the primary device UI
+     * should disable notification sound, vibrating and other visual or aural effects.
+     * This does not change the interruption level, only the effects. **/
+    public static final int HINT_HOST_DISABLE_EFFECTS = 1 << 2;
 
     private INotificationListenerWrapper mWrapper = null;
     private RankingMap mRankingMap;
@@ -174,11 +189,11 @@
 
     /**
      * Implement this method to be notified when the
-     * {@link #getCurrentListenerFlags() listener flags} change.
+     * {@link #getCurrentListenerHints() Listener hints} change.
      *
-     * @param flags The current {@link #getCurrentListenerFlags() listener flags}.
+     * @param hints The current {@link #getCurrentListenerHints() listener hints}.
      */
-    public void onListenerFlagsChanged(int flags) {
+    public void onListenerHintsChanged(int hints) {
         // optional
     }
 
@@ -311,40 +326,40 @@
     }
 
     /**
-     * Gets the set of flags representing current state.
+     * Gets the set of hints representing current state.
      *
      * <p>
-     * The current state may differ from the requested state if the flag represents state
+     * The current state may differ from the requested state if the hint represents state
      * shared across all listeners or a feature the notification host does not support or refuses
      * to grant.
      *
-     * @return One or more of the FLAG_ constants.
+     * @return One or more of the HINT_ constants.
      */
-    public final int getCurrentListenerFlags() {
-        if (!isBound()) return FLAG_NONE;
+    public final int getCurrentListenerHints() {
+        if (!isBound()) return HINTS_NONE;
         try {
-            return getNotificationInterface().getFlagsFromListener(mWrapper);
+            return getNotificationInterface().getHintsFromListener(mWrapper);
         } catch (android.os.RemoteException ex) {
             Log.v(TAG, "Unable to contact notification manager", ex);
-            return FLAG_NONE;
+            return HINTS_NONE;
         }
     }
 
     /**
-     * Sets the desired {@link #getCurrentListenerFlags() listener flags}.
+     * Sets the desired {@link #getCurrentListenerHints() listener hints}.
      *
      * <p>
      * This is merely a request, the host may or not choose to take action depending
      * on other listener requests or other global state.
      * <p>
-     * Listen for updates using {@link #onListenerFlagsChanged(int)}.
+     * Listen for updates using {@link #onListenerHintsChanged(int)}.
      *
-     * @param flags One or more of the FLAG_ constants.
+     * @param hints One or more of the HINT_ constants.
      */
-    public final void requestListenerFlags(int flags) {
+    public final void requestListenerHints(int hints) {
         if (!isBound()) return;
         try {
-            getNotificationInterface().requestFlagsFromListener(mWrapper, flags);
+            getNotificationInterface().requestHintsFromListener(mWrapper, hints);
         } catch (android.os.RemoteException ex) {
             Log.v(TAG, "Unable to contact notification manager", ex);
         }
@@ -480,11 +495,11 @@
             }
         }
         @Override
-        public void onListenerFlagsChanged(int flags) throws RemoteException {
+        public void onListenerHintsChanged(int hints) throws RemoteException {
             try {
-                NotificationListenerService.this.onListenerFlagsChanged(flags);
+                NotificationListenerService.this.onListenerHintsChanged(hints);
             } catch (Throwable t) {
-                Log.w(TAG, "Error running onListenerFlagsChanged", t);
+                Log.w(TAG, "Error running onListenerHintsChanged", t);
             }
         }
     }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 8c2048d..e585807 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6901,6 +6901,7 @@
      *
      * @return true if the view is currently pressed, false otherwise
      */
+    @ViewDebug.ExportedProperty
     public boolean isPressed() {
         return (mPrivateFlags & PFLAG_PRESSED) == PFLAG_PRESSED;
     }
diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java
index 326d1dd..bae0cfb 100644
--- a/core/java/android/view/ViewPropertyAnimator.java
+++ b/core/java/android/view/ViewPropertyAnimator.java
@@ -253,9 +253,6 @@
     ViewPropertyAnimator(View view) {
         mView = view;
         view.ensureTransformationInfo();
-        if (view.getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.L) {
-            mRTBackend = new ViewPropertyAnimatorRT(view);
-        }
     }
 
     /**
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index d93ca2c..23894ee 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -175,7 +175,9 @@
         String[] nativePaths = null;
         try {
             nativePaths = getWebViewNativeLibraryPaths();
-        } catch (PackageManager.NameNotFoundException e) {
+        } catch (Throwable t) {
+            // Log and discard errors at this stage as we must not crash the system server.
+            Log.e(LOGTAG, "error preparing webview native library", t);
         }
         prepareWebViewInSystemServer(nativePaths);
     }
@@ -201,35 +203,37 @@
         String[] nativeLibs = null;
         try {
             nativeLibs = WebViewFactory.getWebViewNativeLibraryPaths();
-        } catch (PackageManager.NameNotFoundException e) {
-        }
+            if (nativeLibs != null) {
+                long newVmSize = 0L;
 
-        if (nativeLibs != null) {
-            long newVmSize = 0L;
-
-            for (String path : nativeLibs) {
-                if (DEBUG) Log.d(LOGTAG, "Checking file size of " + path);
-                if (path == null) continue;
-                File f = new File(path);
-                if (f.exists()) {
-                    long length = f.length();
-                    if (length > newVmSize) {
-                        newVmSize = length;
+                for (String path : nativeLibs) {
+                    if (DEBUG) Log.d(LOGTAG, "Checking file size of " + path);
+                    if (path == null) continue;
+                    File f = new File(path);
+                    if (f.exists()) {
+                        long length = f.length();
+                        if (length > newVmSize) {
+                            newVmSize = length;
+                        }
                     }
                 }
-            }
 
-            if (DEBUG) {
-                Log.v(LOGTAG, "Based on library size, need " + newVmSize +
-                        " bytes of address space.");
+                if (DEBUG) {
+                    Log.v(LOGTAG, "Based on library size, need " + newVmSize +
+                            " bytes of address space.");
+                }
+                // The required memory can be larger than the file on disk (due to .bss), and an
+                // upgraded version of the library will likely be larger, so always attempt to
+                // reserve twice as much as we think to allow for the library to grow during this
+                // boot cycle.
+                newVmSize = Math.max(2 * newVmSize, CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES);
+                Log.d(LOGTAG, "Setting new address space to " + newVmSize);
+                SystemProperties.set(CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY,
+                        Long.toString(newVmSize));
             }
-            // The required memory can be larger than the file on disk (due to .bss), and an
-            // upgraded version of the library will likely be larger, so always attempt to reserve
-            // twice as much as we think to allow for the library to grow during this boot cycle.
-            newVmSize = Math.max(2 * newVmSize, CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES);
-            Log.d(LOGTAG, "Setting new address space to " + newVmSize);
-            SystemProperties.set(CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY,
-                    Long.toString(newVmSize));
+        } catch (Throwable t) {
+            // Log and discard errors at this stage as we must not crash the system server.
+            Log.e(LOGTAG, "error preparing webview native library", t);
         }
         prepareWebViewInSystemServer(nativeLibs);
     }
diff --git a/core/java/com/android/internal/appwidget/IAppWidgetService.aidl b/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
index 9da1c9d..008d38b 100644
--- a/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
+++ b/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
@@ -41,7 +41,8 @@
     void deleteAllHosts();
     RemoteViews getAppWidgetViews(String callingPackage, int appWidgetId);
     int[] getAppWidgetIdsForHost(String callingPackage, int hostId);
-    IntentSender createAppWidgetConfigIntentSender(String callingPackage, in Intent intent);
+    IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId,
+            int intentFlags);
 
     //
     // for AppWidgetManager
@@ -53,8 +54,8 @@
             in RemoteViews views);
     void updateAppWidgetProvider(in ComponentName provider, in RemoteViews views);
     void notifyAppWidgetViewDataChanged(String packageName, in int[] appWidgetIds, int viewId);
-    List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter,
-            in int[] profileIds);
+    List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter,
+            int profileId);
     AppWidgetProviderInfo getAppWidgetInfo(String callingPackage, int appWidgetId);
     boolean hasBindAppWidgetPermission(in String packageName, int userId);
     void setBindAppWidgetPermission(in String packageName, int userId, in boolean permission);
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index f6c0d71..e81ec69 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5209,14 +5209,10 @@
         <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 -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 67352d7..60aacf2 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2118,11 +2118,9 @@
   <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/strings.xml b/core/res/res/values/strings.xml
index dd1d433..4659ace 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2107,9 +2107,9 @@
     <string name="permdesc_cache_filesystem">Allows the app to read and write the cache filesystem.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_use_sip">make/receive Internet calls</string>
+    <string name="permlab_use_sip">make/receive SIP calls</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_use_sip">Allows the app to use the SIP service to make/receive Internet calls.</string>
+    <string name="permdesc_use_sip">Allows the app to make and receive SIP calls.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_bind_call_service">interact with in-call screen</string>
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index cf675ed..f097239 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -225,8 +225,7 @@
             if (stateSet[i] == R.attr.state_enabled) {
                 enabled = true;
             }
-            if (stateSet[i] == R.attr.state_focused
-                    || stateSet[i] == R.attr.state_selected) {
+            if (stateSet[i] == R.attr.state_focused) {
                 focused = true;
             }
             if (stateSet[i] == R.attr.state_pressed) {
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 1a96b2f..d9f7941 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -100,6 +100,9 @@
 		LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
 	endif
 
+	# Defaults for ATRACE_TAG and LOG_TAG for libhwui
+	LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\"
+
 	include $(BUILD_SHARED_LIBRARY)
 
 	include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp
index dd2e2fd..5ecd77a 100644
--- a/libs/hwui/Animator.cpp
+++ b/libs/hwui/Animator.cpp
@@ -249,6 +249,10 @@
     mProperty->value = value;
 }
 
+uint32_t CanvasPropertyPrimitiveAnimator::dirtyMask() {
+    return RenderNode::DISPLAY_LIST;
+}
+
 /************************************************************
  *  CanvasPropertySkPaintAnimator
  ************************************************************/
@@ -288,6 +292,10 @@
     LOG_ALWAYS_FATAL("Unknown field %d", (int) mField);
 }
 
+uint32_t CanvasPropertyPaintAnimator::dirtyMask() {
+    return RenderNode::DISPLAY_LIST;
+}
+
 RevealAnimator::RevealAnimator(int centerX, int centerY,
         float startValue, float finalValue)
         : BaseRenderNodeAnimator(finalValue)
@@ -305,5 +313,9 @@
             mCenterX, mCenterY, value);
 }
 
+uint32_t RevealAnimator::dirtyMask() {
+    return RenderNode::GENERIC;
+}
+
 } /* namespace uirenderer */
 } /* namespace android */
diff --git a/libs/hwui/Animator.h b/libs/hwui/Animator.h
index b0dcf2d..6dfe7b4 100644
--- a/libs/hwui/Animator.h
+++ b/libs/hwui/Animator.h
@@ -62,7 +62,7 @@
     bool isFinished() { return mPlayState == FINISHED; }
     float finalValue() { return mFinalValue; }
 
-    ANDROID_API virtual uint32_t dirtyMask() { return 0; }
+    ANDROID_API virtual uint32_t dirtyMask() = 0;
 
 protected:
     BaseRenderNodeAnimator(float finalValue);
@@ -145,6 +145,9 @@
 public:
     ANDROID_API CanvasPropertyPrimitiveAnimator(CanvasPropertyPrimitive* property,
             float finalValue);
+
+    ANDROID_API virtual uint32_t dirtyMask();
+
 protected:
     virtual float getValue(RenderNode* target) const;
     virtual void setValue(RenderNode* target, float value);
@@ -161,6 +164,9 @@
 
     ANDROID_API CanvasPropertyPaintAnimator(CanvasPropertyPaint* property,
             PaintField field, float finalValue);
+
+    ANDROID_API virtual uint32_t dirtyMask();
+
 protected:
     virtual float getValue(RenderNode* target) const;
     virtual void setValue(RenderNode* target, float value);
@@ -173,13 +179,15 @@
 public:
     ANDROID_API RevealAnimator(int centerX, int centerY,
             float startValue, float finalValue);
+
+    ANDROID_API virtual uint32_t dirtyMask();
+
 protected:
     virtual float getValue(RenderNode* target) const;
     virtual void setValue(RenderNode* target, float value);
 
 private:
     int mCenterX, mCenterY;
-    bool mInverseClip;
 };
 
 } /* namespace uirenderer */
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index 27b0893..7221295a4 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -66,22 +66,26 @@
 class AnimateFunctor {
 public:
     AnimateFunctor(RenderNode& target, TreeInfo& info)
-            : mTarget(target), mInfo(info) {}
+            : dirtyMask(0), mTarget(target), mInfo(info) {}
 
     bool operator() (BaseRenderNodeAnimator* animator) {
+        dirtyMask |= animator->dirtyMask();
         bool remove = animator->animate(mInfo);
         if (remove) {
             animator->decStrong(0);
         }
         return remove;
     }
+
+    uint32_t dirtyMask;
+
 private:
     RenderNode& mTarget;
     TreeInfo& mInfo;
 };
 
-void AnimatorManager::animate(TreeInfo& info) {
-    if (!mAnimators.size()) return;
+uint32_t AnimatorManager::animate(TreeInfo& info) {
+    if (!mAnimators.size()) return 0;
 
     // TODO: Can we target this better? For now treat it like any other staging
     // property push and just damage self before and after animators are run
@@ -97,6 +101,8 @@
     mParent.mProperties.updateMatrix();
     info.damageAccumulator->pushTransform(&mParent);
     mParent.damageSelf(info);
+
+    return functor.dirtyMask;
 }
 
 } /* namespace uirenderer */
diff --git a/libs/hwui/AnimatorManager.h b/libs/hwui/AnimatorManager.h
index 2568121..0d177c5 100644
--- a/libs/hwui/AnimatorManager.h
+++ b/libs/hwui/AnimatorManager.h
@@ -40,7 +40,8 @@
     void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
 
     void pushStaging(TreeInfo& info);
-    void animate(TreeInfo& info);
+    // Returns the combined dirty mask of all animators run
+    uint32_t animate(TreeInfo& info);
 
 private:
     RenderNode& mParent;
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 8b32c40..15bed58 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -83,11 +83,6 @@
     mHead->matrix4 = transform;
 }
 
-void DamageAccumulator::pushNullTransform() {
-    pushCommon();
-    mHead->type = TransformNone;
-}
-
 void DamageAccumulator::popTransform() {
     LOG_ALWAYS_FATAL_IF(mHead->prev == mHead, "Cannot pop the root frame!");
     DirtyStack* dirtyFrame = mHead;
diff --git a/libs/hwui/DamageAccumulator.h b/libs/hwui/DamageAccumulator.h
index fc9b41b..90d9425 100644
--- a/libs/hwui/DamageAccumulator.h
+++ b/libs/hwui/DamageAccumulator.h
@@ -35,7 +35,6 @@
 public:
     virtual void pushTransform(const RenderNode* transform) = 0;
     virtual void pushTransform(const Matrix4* transform) = 0;
-    virtual void pushNullTransform() = 0;
     virtual void popTransform() = 0;
     virtual void dirty(float left, float top, float right, float bottom) = 0;
     virtual void peekAtDirty(SkRect* dest) = 0;
@@ -54,9 +53,6 @@
     // will be affected by the transform when popTransform() is called.
     virtual void pushTransform(const RenderNode* transform);
     virtual void pushTransform(const Matrix4* transform);
-    // This is used in combination with peekAtDirty to inspect the damage
-    // area of a subtree
-    virtual void pushNullTransform();
 
     // Pops a transform node from the stack, propagating the dirty rect
     // up to the parent node. Returns the IDamageTransform that was just applied
@@ -83,7 +79,6 @@
 public:
     virtual void pushTransform(const RenderNode* transform) { }
     virtual void pushTransform(const Matrix4* transform) { }
-    virtual void pushNullTransform() { }
     virtual void popTransform() { }
     virtual void dirty(float left, float top, float right, float bottom) { }
     virtual void peekAtDirty(SkRect* dest) { dest->setEmpty(); }
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 396c7f3..636f218 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -598,6 +598,7 @@
 }
 
 void OpenGLRenderer::flushLayerUpdates() {
+    ATRACE_CALL();
     syncState();
     updateLayers();
     flushLayers();
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 23940ee..c59b010 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -136,13 +136,18 @@
     }
 }
 
-void RenderNode::prepareLayer(TreeInfo& info) {
+void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
     LayerType layerType = properties().layerProperties().type();
     if (CC_UNLIKELY(layerType == kLayerTypeRenderLayer)) {
-        // We push a null transform here as we don't care what the existing dirty
-        // area is, only what our display list dirty is as well as our children's
-        // dirty area
-        info.damageAccumulator->pushNullTransform();
+        // Damage applied so far needs to affect our parent, but does not require
+        // the layer to be updated. So we pop/push here to clear out the current
+        // damage and get a clean state for display list or children updates to
+        // affect, which will require the layer to be updated
+        info.damageAccumulator->popTransform();
+        info.damageAccumulator->pushTransform(this);
+        if (dirtyMask & DISPLAY_LIST) {
+            damageSelf(info);
+        }
     }
 }
 
@@ -151,9 +156,6 @@
     // If we are not a layer OR we cannot be rendered (eg, view was detached)
     // we need to destroy any Layers we may have had previously
     if (CC_LIKELY(layerType != kLayerTypeRenderLayer) || CC_UNLIKELY(!isRenderable())) {
-        if (layerType == kLayerTypeRenderLayer) {
-            info.damageAccumulator->popTransform();
-        }
         if (CC_UNLIKELY(mLayer)) {
             LayerRenderer::destroyLayer(mLayer);
             mLayer = NULL;
@@ -175,7 +177,6 @@
 
     SkRect dirty;
     info.damageAccumulator->peekAtDirty(&dirty);
-    info.damageAccumulator->popTransform();
 
     if (!mLayer) {
         if (info.errorHandler) {
@@ -204,8 +205,8 @@
     if (info.mode == TreeInfo::MODE_FULL) {
         pushStagingPropertiesChanges(info);
     }
-    mAnimatorManager.animate(info);
-    prepareLayer(info);
+    uint32_t animatorDirtyMask = mAnimatorManager.animate(info);
+    prepareLayer(info, animatorDirtyMask);
     if (info.mode == TreeInfo::MODE_FULL) {
         pushStagingDisplayListChanges(info);
     }
diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h
index 8cc65b2..fa310e0 100644
--- a/libs/hwui/RenderNode.h
+++ b/libs/hwui/RenderNode.h
@@ -90,6 +90,7 @@
         Y               = 1 << 11,
         Z               = 1 << 12,
         ALPHA           = 1 << 13,
+        DISPLAY_LIST    = 1 << 14,
     };
 
     ANDROID_API RenderNode();
@@ -244,7 +245,7 @@
     void pushStagingDisplayListChanges(TreeInfo& info);
     void prepareSubTree(TreeInfo& info, DisplayListData* subtree);
     void applyLayerPropertiesToLayer(TreeInfo& info);
-    void prepareLayer(TreeInfo& info);
+    void prepareLayer(TreeInfo& info, uint32_t dirtyMask);
     void pushLayerUpdate(TreeInfo& info);
     void deleteDisplayListData();
     void damageSelf(TreeInfo& info);
diff --git a/media/java/android/media/MediaMetadata.java b/media/java/android/media/MediaMetadata.java
index bbf6a3b..74f7a96 100644
--- a/media/java/android/media/MediaMetadata.java
+++ b/media/java/android/media/MediaMetadata.java
@@ -190,8 +190,8 @@
 
     private static final String[] PREFERRED_DESCRIPTION_ORDER = {
             METADATA_KEY_TITLE,
-            METADATA_KEY_ALBUM,
             METADATA_KEY_ARTIST,
+            METADATA_KEY_ALBUM,
             METADATA_KEY_ALBUM_ARTIST,
             METADATA_KEY_WRITER,
             METADATA_KEY_AUTHOR,
@@ -215,7 +215,6 @@
     private static final int METADATA_TYPE_TEXT = 1;
     private static final int METADATA_TYPE_BITMAP = 2;
     private static final int METADATA_TYPE_RATING = 3;
-    private static final int METADATA_TYPE_URI = 4;
     private static final ArrayMap<String, Integer> METADATA_KEYS_TYPE;
 
     static {
@@ -236,16 +235,16 @@
         METADATA_KEYS_TYPE.put(METADATA_KEY_DISC_NUMBER, METADATA_TYPE_LONG);
         METADATA_KEYS_TYPE.put(METADATA_KEY_ALBUM_ARTIST, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_ART, METADATA_TYPE_BITMAP);
-        METADATA_KEYS_TYPE.put(METADATA_KEY_ART_URI, METADATA_TYPE_URI);
+        METADATA_KEYS_TYPE.put(METADATA_KEY_ART_URI, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_ALBUM_ART, METADATA_TYPE_BITMAP);
-        METADATA_KEYS_TYPE.put(METADATA_KEY_ALBUM_ART_URI, METADATA_TYPE_URI);
+        METADATA_KEYS_TYPE.put(METADATA_KEY_ALBUM_ART_URI, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_USER_RATING, METADATA_TYPE_RATING);
         METADATA_KEYS_TYPE.put(METADATA_KEY_RATING, METADATA_TYPE_RATING);
         METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_TITLE, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_SUBTITLE, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_DESCRIPTION, METADATA_TYPE_TEXT);
         METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_ICON, METADATA_TYPE_BITMAP);
-        METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_ICON_URI, METADATA_TYPE_URI);
+        METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_ICON_URI, METADATA_TYPE_TEXT);
     }
 
     private static final SparseArray<String> EDITOR_KEY_MAPPING;
@@ -406,7 +405,6 @@
      * Returns a simple description of this metadata for display purposes.
      *
      * @return A simple description of this metadata.
-     * @hide
      */
     public @NonNull Description getDescription() {
         if (mDescription != null) {
@@ -673,43 +671,86 @@
 
     /**
      * A simple form of the metadata that can be used for display.
-     *
-     * @hide
      */
     public final class Description {
         /**
          * A primary title suitable for display or null.
          */
-        public final CharSequence title;
+        private final CharSequence mTitle;
         /**
          * A subtitle suitable for display or null.
          */
-        public final CharSequence subtitle;
+        private final CharSequence mSubtitle;
         /**
          * A description suitable for display or null.
          */
-        public final CharSequence description;
+        private final CharSequence mDescription;
         /**
          * A bitmap icon suitable for display or null.
          */
-        public final Bitmap icon;
+        private final Bitmap mIcon;
         /**
          * A Uri for an icon suitable for display or null.
          */
-        public final Uri iconUri;
+        private final Uri mIconUri;
+
+        /**
+         * Returns the best available title or null.
+         *
+         * @return A title or null.
+         */
+        public @Nullable CharSequence getTitle() {
+            return mTitle;
+        }
+
+        /**
+         * Returns the best available subtitle or null.
+         *
+         * @return A subtitle or null.
+         */
+        public @Nullable CharSequence getSubtitle() {
+            return mSubtitle;
+        }
+
+        /**
+         * Returns the best available description or null.
+         *
+         * @return A description or null.
+         */
+        public @Nullable CharSequence getDescription() {
+            return mDescription;
+        }
+
+        /**
+         * Returns the best available icon or null.
+         *
+         * @return An icon or null.
+         */
+        public @Nullable Bitmap getIcon() {
+            return mIcon;
+        }
+
+        /**
+         * Returns the best available icon Uri or null.
+         *
+         * @return An icon uri or null.
+         */
+        public @Nullable Uri getIconUri() {
+            return mIconUri;
+        }
 
         private Description(CharSequence title, CharSequence subtitle, CharSequence description,
                 Bitmap icon, Uri iconUri) {
-            this.title = title;
-            this.subtitle = subtitle;
-            this.description = description;
-            this.icon = icon;
-            this.iconUri = iconUri;
+            mTitle = title;
+            mSubtitle = subtitle;
+            mDescription = description;
+            mIcon = icon;
+            mIconUri = iconUri;
         }
 
         @Override
         public String toString() {
-            return title + ", " + subtitle + ", " + description;
+            return mTitle + ", " + mSubtitle + ", " + mDescription;
         }
     }
 
diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java
index 96c66c5..2a0fd83 100644
--- a/media/java/android/media/RemoteControlClient.java
+++ b/media/java/android/media/RemoteControlClient.java
@@ -970,8 +970,7 @@
     public final static int RCSE_ID_UNREGISTERED = -1;
 
     // USE_SESSIONS
-    private MediaSession.TransportControlsCallback mTransportListener
-            = new MediaSession.TransportControlsCallback() {
+    private MediaSession.Callback mTransportListener = new MediaSession.Callback() {
 
         @Override
         public void onSeekTo(long pos) {
diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java
index e3c198e..f6e189a 100644
--- a/media/java/android/media/session/MediaController.java
+++ b/media/java/android/media/session/MediaController.java
@@ -179,7 +179,8 @@
     }
 
     /**
-     * Get the current play queue for this session.
+     * Get the current play queue for this session if one is set. If you only
+     * care about the current item {@link #getMetadata()} should be used.
      *
      * @return The current play queue or null.
      */
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index cf8e3dd..cf73c2a 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -21,12 +21,10 @@
 import android.annotation.Nullable;
 import android.app.Activity;
 import android.app.PendingIntent;
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ParceledListSlice;
 import android.media.AudioAttributes;
-import android.media.AudioManager;
 import android.media.MediaMetadata;
 import android.media.Rating;
 import android.media.VolumeProvider;
@@ -43,11 +41,11 @@
 import android.os.UserHandle;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.KeyEvent;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.ref.WeakReference;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -64,10 +62,8 @@
  * create a {@link MediaController} to interact with the session.
  * <p>
  * To receive commands, media keys, and other events a {@link Callback} must be
- * set with {@link #addCallback(Callback)} and {@link #setActive(boolean)
- * setActive(true)} must be called. To receive transport control commands a
- * {@link TransportControlsCallback} must be set with
- * {@link #addTransportControlsCallback}.
+ * set with {@link #setCallback(Callback)} and {@link #setActive(boolean)
+ * setActive(true)} must be called.
  * <p>
  * When an app is finished performing playback it must call {@link #release()}
  * to clean up the session and notify any controllers.
@@ -85,8 +81,7 @@
 
     /**
      * Set this flag on the session to indicate that it handles transport
-     * control commands through a {@link TransportControlsCallback}.
-     * The callback can be retrieved by calling {@link #addTransportControlsCallback}.
+     * control commands through its {@link Callback}.
      */
     public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 1 << 1;
 
@@ -124,12 +119,9 @@
     private final ISession mBinder;
     private final CallbackStub mCbStub;
 
-    private final ArrayList<CallbackMessageHandler> mCallbacks
-            = new ArrayList<CallbackMessageHandler>();
-    private final ArrayList<TransportMessageHandler> mTransportCallbacks
-            = new ArrayList<TransportMessageHandler>();
-
+    private CallbackMessageHandler mCallback;
     private VolumeProvider mVolumeProvider;
+    private PlaybackState mPlaybackState;
 
     private boolean mActive = false;
 
@@ -177,30 +169,35 @@
     }
 
     /**
-     * Add a callback to receive updates on for the MediaSession. This includes
-     * media button and volume events. The caller's thread will be used to post
-     * events.
+     * Set the callback to receive updates for the MediaSession. This includes
+     * media button events and transport controls. The caller's thread will be
+     * used to post updates.
+     * <p>
+     * Set the callback to null to stop receiving updates.
      *
      * @param callback The callback object
      */
-    public void addCallback(@NonNull Callback callback) {
-        addCallback(callback, null);
+    public void setCallback(@Nullable Callback callback) {
+        setCallback(callback, null);
     }
 
     /**
-     * Add a callback to receive updates for the MediaSession. This includes
-     * media button and volume events.
+     * Set the callback to receive updates for the MediaSession. This includes
+     * media button events and transport controls.
+     * <p>
+     * Set the callback to null to stop receiving updates.
      *
      * @param callback The callback to receive updates on.
      * @param handler The handler that events should be posted on.
      */
-    public void addCallback(@NonNull Callback callback, @Nullable Handler handler) {
+    public void setCallback(@Nullable Callback callback, @Nullable Handler handler) {
         if (callback == null) {
-            throw new IllegalArgumentException("Callback cannot be null");
+            mCallback = null;
+            return;
         }
         synchronized (mLock) {
-            if (getHandlerForCallbackLocked(callback) != null) {
-                Log.w(TAG, "Callback is already added, ignoring");
+            if (mCallback != null && mCallback.mCallback == callback) {
+                Log.w(TAG, "Tried to set same callback, ignoring");
                 return;
             }
             if (handler == null) {
@@ -208,18 +205,7 @@
             }
             CallbackMessageHandler msgHandler = new CallbackMessageHandler(handler.getLooper(),
                     callback);
-            mCallbacks.add(msgHandler);
-        }
-    }
-
-    /**
-     * Remove a callback. It will no longer receive updates.
-     *
-     * @param callback The callback to remove.
-     */
-    public void removeCallback(@NonNull Callback callback) {
-        synchronized (mLock) {
-            removeCallbackLocked(callback);
+            mCallback = msgHandler;
         }
     }
 
@@ -421,63 +407,12 @@
     }
 
     /**
-     * Add a callback to receive transport controls on, such as play, rewind, or
-     * fast forward.
-     *
-     * @param callback The callback object
-     */
-    public void addTransportControlsCallback(@NonNull TransportControlsCallback callback) {
-        addTransportControlsCallback(callback, null);
-    }
-
-    /**
-     * Add a callback to receive transport controls on, such as play, rewind, or
-     * fast forward. The updates will be posted to the specified handler. If no
-     * handler is provided they will be posted to the caller's thread.
-     *
-     * @param callback The callback to receive updates on
-     * @param handler The handler to post the updates on
-     */
-    public void addTransportControlsCallback(@NonNull TransportControlsCallback callback,
-            @Nullable Handler handler) {
-        if (callback == null) {
-            throw new IllegalArgumentException("Callback cannot be null");
-        }
-        synchronized (mLock) {
-            if (getTransportControlsHandlerForCallbackLocked(callback) != null) {
-                Log.w(TAG, "Callback is already added, ignoring");
-                return;
-            }
-            if (handler == null) {
-                handler = new Handler();
-            }
-            TransportMessageHandler msgHandler = new TransportMessageHandler(handler.getLooper(),
-                    callback);
-            mTransportCallbacks.add(msgHandler);
-        }
-    }
-
-    /**
-     * Stop receiving transport controls on the specified callback. If an update
-     * has already been posted you may still receive it after this call returns.
-     *
-     * @param callback The callback to stop receiving updates on
-     */
-    public void removeTransportControlsCallback(@NonNull TransportControlsCallback callback) {
-        if (callback == null) {
-            throw new IllegalArgumentException("Callback cannot be null");
-        }
-        synchronized (mLock) {
-            removeTransportControlsCallbackLocked(callback);
-        }
-    }
-
-    /**
      * Update the current playback state.
      *
      * @param state The current state of playback
      */
     public void setPlaybackState(@Nullable PlaybackState state) {
+        mPlaybackState = state;
         try {
             mBinder.setPlaybackState(state);
         } catch (RemoteException e) {
@@ -566,138 +501,78 @@
     }
 
     private void dispatchPlay() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_PLAY);
+        postToCallback(CallbackMessageHandler.MSG_PLAY);
     }
 
     private void dispatchPlayUri(Uri uri, Bundle extras) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_PLAY_URI, uri, extras);
+        postToCallback(CallbackMessageHandler.MSG_PLAY_URI, uri, extras);
     }
 
     private void dispatchPlayFromSearch(String query, Bundle extras) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_PLAY_SEARCH, query, extras);
+        postToCallback(CallbackMessageHandler.MSG_PLAY_SEARCH, query, extras);
     }
 
     private void dispatchSkipToTrack(long id) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_SKIP_TO_TRACK, id);
+        postToCallback(CallbackMessageHandler.MSG_SKIP_TO_TRACK, id);
     }
 
     private void dispatchPause() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_PAUSE);
+        postToCallback(CallbackMessageHandler.MSG_PAUSE);
     }
 
     private void dispatchStop() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_STOP);
+        postToCallback(CallbackMessageHandler.MSG_STOP);
     }
 
     private void dispatchNext() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_NEXT);
+        postToCallback(CallbackMessageHandler.MSG_NEXT);
     }
 
     private void dispatchPrevious() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_PREVIOUS);
+        postToCallback(CallbackMessageHandler.MSG_PREVIOUS);
     }
 
     private void dispatchFastForward() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_FAST_FORWARD);
+        postToCallback(CallbackMessageHandler.MSG_FAST_FORWARD);
     }
 
     private void dispatchRewind() {
-        postToTransportCallbacks(TransportMessageHandler.MSG_REWIND);
+        postToCallback(CallbackMessageHandler.MSG_REWIND);
     }
 
     private void dispatchSeekTo(long pos) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_SEEK_TO, pos);
+        postToCallback(CallbackMessageHandler.MSG_SEEK_TO, pos);
     }
 
     private void dispatchRate(Rating rating) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_RATE, rating);
+        postToCallback(CallbackMessageHandler.MSG_RATE, rating);
     }
 
     private void dispatchCustomAction(String action, Bundle args) {
-        postToTransportCallbacks(TransportMessageHandler.MSG_CUSTOM_ACTION, action, args);
+        postToCallback(CallbackMessageHandler.MSG_CUSTOM_ACTION, action, args);
     }
 
-    private TransportMessageHandler getTransportControlsHandlerForCallbackLocked(
-            TransportControlsCallback callback) {
-        for (int i = mTransportCallbacks.size() - 1; i >= 0; i--) {
-            TransportMessageHandler handler = mTransportCallbacks.get(i);
-            if (callback == handler.mCallback) {
-                return handler;
-            }
-        }
-        return null;
+    private void dispatchMediaButton(Intent mediaButtonIntent) {
+        postToCallback(CallbackMessageHandler.MSG_MEDIA_BUTTON, mediaButtonIntent);
     }
 
-    private boolean removeTransportControlsCallbackLocked(TransportControlsCallback callback) {
-        for (int i = mTransportCallbacks.size() - 1; i >= 0; i--) {
-            if (callback == mTransportCallbacks.get(i).mCallback) {
-                mTransportCallbacks.remove(i);
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void postToTransportCallbacks(int what, Object obj) {
-        synchronized (mLock) {
-            for (int i = mTransportCallbacks.size() - 1; i >= 0; i--) {
-                mTransportCallbacks.get(i).post(what, obj);
-            }
-        }
-    }
-
-    private void postToTransportCallbacks(int what, Object obj, Bundle args) {
-        synchronized (mLock) {
-            for (int i = mTransportCallbacks.size() - 1; i >= 0; i--) {
-                mTransportCallbacks.get(i).post(what, obj, args);
-            }
-        }
-    }
-
-    private void postToTransportCallbacks(int what) {
-        postToTransportCallbacks(what, null);
-    }
-
-    private CallbackMessageHandler getHandlerForCallbackLocked(Callback cb) {
-        if (cb == null) {
-            throw new IllegalArgumentException("Callback cannot be null");
-        }
-        for (int i = mCallbacks.size() - 1; i >= 0; i--) {
-            CallbackMessageHandler handler = mCallbacks.get(i);
-            if (cb == handler.mCallback) {
-                return handler;
-            }
-        }
-        return null;
-    }
-
-    private boolean removeCallbackLocked(Callback cb) {
-        if (cb == null) {
-            throw new IllegalArgumentException("Callback cannot be null");
-        }
-        for (int i = mCallbacks.size() - 1; i >= 0; i--) {
-            CallbackMessageHandler handler = mCallbacks.get(i);
-            if (cb == handler.mCallback) {
-                mCallbacks.remove(i);
-                return true;
-            }
-        }
-        return false;
+    private void postToCallback(int what) {
+        postToCallback(what, null);
     }
 
     private void postCommand(String command, Bundle args, ResultReceiver resultCb) {
         Command cmd = new Command(command, args, resultCb);
-        synchronized (mLock) {
-            for (int i = mCallbacks.size() - 1; i >= 0; i--) {
-                mCallbacks.get(i).post(CallbackMessageHandler.MSG_COMMAND, cmd);
-            }
-        }
+        postToCallback(CallbackMessageHandler.MSG_COMMAND, cmd);
     }
 
-    private void postMediaButton(Intent mediaButtonIntent) {
+    private void postToCallback(int what, Object obj) {
+        postToCallback(what, obj, null);
+    }
+
+    private void postToCallback(int what, Object obj, Bundle extras) {
         synchronized (mLock) {
-            for (int i = mCallbacks.size() - 1; i >= 0; i--) {
-                mCallbacks.get(i).post(CallbackMessageHandler.MSG_MEDIA_BUTTON, mediaButtonIntent);
+            if (mCallback != null) {
+                mCallback.post(what, obj, extras);
             }
         }
     }
@@ -791,30 +666,16 @@
     }
 
     /**
-     * Receives generic commands or updates from controllers and the system.
-     * Callbacks may be registered using {@link #addCallback}.
+     * Receives media buttons, transport controls, and commands from controllers
+     * and the system. A callback may be set using {@link #setCallback}.
      */
     public abstract static class Callback {
+        private MediaSession mSession;
 
         public Callback() {
         }
 
         /**
-         * Called when a media button is pressed and this session has the
-         * highest priority or a controller sends a media button event to the
-         * session. TODO determine if using Intents identical to the ones
-         * RemoteControlClient receives is useful
-         * <p>
-         * The intent will be of type {@link Intent#ACTION_MEDIA_BUTTON} with a
-         * KeyEvent in {@link Intent#EXTRA_KEY_EVENT}
-         *
-         * @param mediaButtonIntent an intent containing the KeyEvent as an
-         *            extra
-         */
-        public void onMediaButtonEvent(@NonNull Intent mediaButtonIntent) {
-        }
-
-        /**
          * Called when a controller has sent a command to this session.
          * The owner of the session may handle custom commands but is not
          * required to.
@@ -826,13 +687,81 @@
         public void onCommand(@NonNull String command, @Nullable Bundle args,
                 @Nullable ResultReceiver cb) {
         }
-    }
 
-    /**
-     * Receives transport control commands. Callbacks may be registered using
-     * {@link #addTransportControlsCallback}.
-     */
-    public static abstract class TransportControlsCallback {
+        /**
+         * Called when a media button is pressed and this session has the
+         * highest priority or a controller sends a media button event to the
+         * session. The default behavior will call the relevant method if the
+         * action for it was set.
+         * <p>
+         * The intent will be of type {@link Intent#ACTION_MEDIA_BUTTON} with a
+         * KeyEvent in {@link Intent#EXTRA_KEY_EVENT}
+         *
+         * @param mediaButtonIntent an intent containing the KeyEvent as an
+         *            extra
+         */
+        public boolean onMediaButtonEvent(@NonNull Intent mediaButtonIntent) {
+            if (mSession != null
+                    && Intent.ACTION_MEDIA_BUTTON.equals(mediaButtonIntent.getAction())) {
+                KeyEvent ke = mediaButtonIntent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
+                if (ke != null && ke.getAction() == KeyEvent.ACTION_DOWN) {
+                    PlaybackState state = mSession.mPlaybackState;
+                    long validActions = state == null ? 0 : state.getActions();
+                    switch (ke.getKeyCode()) {
+                        case KeyEvent.KEYCODE_MEDIA_PLAY:
+                            if ((validActions & PlaybackState.ACTION_PLAY) != 0) {
+                                onPlay();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_PAUSE:
+                            if ((validActions & PlaybackState.ACTION_PAUSE) != 0) {
+                                onPause();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_NEXT:
+                            if ((validActions & PlaybackState.ACTION_SKIP_TO_NEXT) != 0) {
+                                onSkipToNext();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
+                            if ((validActions & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0) {
+                                onSkipToPrevious();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_STOP:
+                            if ((validActions & PlaybackState.ACTION_STOP) != 0) {
+                                onStop();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
+                            if ((validActions & PlaybackState.ACTION_FAST_FORWARD) != 0) {
+                                onFastForward();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_REWIND:
+                            if ((validActions & PlaybackState.ACTION_REWIND) != 0) {
+                                onRewind();
+                            }
+                            break;
+                        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+                        case KeyEvent.KEYCODE_HEADSETHOOK:
+                            boolean isPlaying = state == null ? false
+                                    : state.getState() == PlaybackState.STATE_PLAYING;
+                            boolean canPlay = (validActions & (PlaybackState.ACTION_PLAY_PAUSE
+                                    | PlaybackState.ACTION_PLAY)) != 0;
+                            boolean canPause = (validActions & (PlaybackState.ACTION_PLAY_PAUSE
+                                    | PlaybackState.ACTION_PAUSE)) != 0;
+                            if (isPlaying && canPause) {
+                                onPause();
+                            } else if (!isPlaying && canPlay) {
+                                onPlay();
+                            }
+                            break;
+                    }
+                }
+            }
+            return false;
+        }
 
         /**
          * Override to handle requests to begin playback.
@@ -920,6 +849,10 @@
          */
         public void onCustomAction(@NonNull String action, @Nullable Bundle extras) {
         }
+
+        private void setSession(MediaSession session) {
+            mSession = session;
+        }
     }
 
     /**
@@ -946,7 +879,7 @@
             MediaSession session = mMediaSession.get();
             try {
                 if (session != null) {
-                    session.postMediaButton(mediaButtonIntent);
+                    session.dispatchMediaButton(mediaButtonIntent);
                 }
             } finally {
                 if (cb != null) {
@@ -1232,44 +1165,6 @@
         }
     }
 
-    private class CallbackMessageHandler extends Handler {
-        private static final int MSG_MEDIA_BUTTON = 1;
-        private static final int MSG_COMMAND = 2;
-
-        private MediaSession.Callback mCallback;
-
-        public CallbackMessageHandler(Looper looper, MediaSession.Callback callback) {
-            super(looper, null, true);
-            mCallback = callback;
-        }
-
-        @Override
-        public void handleMessage(Message msg) {
-            synchronized (mLock) {
-                if (mCallback == null) {
-                    return;
-                }
-                switch (msg.what) {
-                    case MSG_MEDIA_BUTTON:
-                        mCallback.onMediaButtonEvent((Intent) msg.obj);
-                        break;
-                    case MSG_COMMAND:
-                        Command cmd = (Command) msg.obj;
-                        mCallback.onCommand(cmd.command, cmd.extras, cmd.stub);
-                        break;
-                }
-            }
-        }
-
-        public void post(int what, Object obj) {
-            obtainMessage(what, obj).sendToTarget();
-        }
-
-        public void post(int what, Object obj, int arg1) {
-            obtainMessage(what, arg1, 0, obj).sendToTarget();
-        }
-    }
-
     private static final class Command {
         public final String command;
         public final Bundle extras;
@@ -1282,7 +1177,8 @@
         }
     }
 
-    private class TransportMessageHandler extends Handler {
+    private class CallbackMessageHandler extends Handler {
+
         private static final int MSG_PLAY = 1;
         private static final int MSG_PLAY_URI = 2;
         private static final int MSG_PLAY_SEARCH = 3;
@@ -1296,12 +1192,14 @@
         private static final int MSG_SEEK_TO = 11;
         private static final int MSG_RATE = 12;
         private static final int MSG_CUSTOM_ACTION = 13;
+        private static final int MSG_MEDIA_BUTTON = 14;
+        private static final int MSG_COMMAND = 15;
 
-        private TransportControlsCallback mCallback;
+        private MediaSession.Callback mCallback;
 
-        public TransportMessageHandler(Looper looper, TransportControlsCallback cb) {
-            super(looper);
-            mCallback = cb;
+        public CallbackMessageHandler(Looper looper, MediaSession.Callback callback) {
+            super(looper, null, true);
+            mCallback = callback;
         }
 
         public void post(int what, Object obj, Bundle bundle) {
@@ -1318,6 +1216,10 @@
             post(what, null);
         }
 
+        public void post(int what, Object obj, int arg1) {
+            obtainMessage(what, arg1, 0, obj).sendToTarget();
+        }
+
         @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
@@ -1359,6 +1261,13 @@
                 case MSG_CUSTOM_ACTION:
                     mCallback.onCustomAction((String) msg.obj, msg.getData());
                     break;
+                case MSG_MEDIA_BUTTON:
+                    mCallback.onMediaButtonEvent((Intent) msg.obj);
+                    break;
+                case MSG_COMMAND:
+                    Command cmd = (Command) msg.obj;
+                    mCallback.onCommand(cmd.command, cmd.extras, cmd.stub);
+                    break;
             }
         }
     }
diff --git a/media/java/android/media/session/MediaSessionLegacyHelper.java b/media/java/android/media/session/MediaSessionLegacyHelper.java
index f075ded..a182982 100644
--- a/media/java/android/media/session/MediaSessionLegacyHelper.java
+++ b/media/java/android/media/session/MediaSessionLegacyHelper.java
@@ -29,6 +29,9 @@
 import android.media.MediaMetadata;
 import android.media.MediaMetadataEditor;
 import android.media.MediaMetadataRetriever;
+import android.media.Rating;
+import android.media.RemoteControlClient;
+import android.media.RemoteControlClient.MetadataEditor;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
@@ -229,8 +232,7 @@
         }
     }
 
-    public void addRccListener(PendingIntent pi,
-            MediaSession.TransportControlsCallback listener) {
+    public void addRccListener(PendingIntent pi, MediaSession.Callback listener) {
         if (pi == null) {
             Log.w(TAG, "Pending intent was null, can't add rcc listener.");
             return;
@@ -247,10 +249,7 @@
                 // This is already the registered listener, ignore
                 return;
             }
-            // Otherwise it changed so we need to switch to the new one
-            holder.mSession.removeTransportControlsCallback(holder.mRccListener);
         }
-        holder.mSession.addTransportControlsCallback(listener, mHandler);
         holder.mRccListener = listener;
         holder.mFlags |= MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS;
         holder.mSession.setFlags(holder.mFlags);
@@ -266,7 +265,6 @@
         }
         SessionHolder holder = getHolder(pi, false);
         if (holder != null && holder.mRccListener != null) {
-            holder.mSession.removeTransportControlsCallback(holder.mRccListener);
             holder.mRccListener = null;
             holder.mFlags &= ~MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS;
             holder.mSession.setFlags(holder.mFlags);
@@ -288,8 +286,7 @@
             return;
         }
         if (holder.mMediaButtonListener != null) {
-            // Already have this listener registered, but update it anyway as
-            // the extras may have changed.
+            // Already have this listener registered
             if (DEBUG) {
                 Log.d(TAG, "addMediaButtonListener already added " + pi);
             }
@@ -300,11 +297,8 @@
         // set this flag
         holder.mFlags |= MediaSession.FLAG_HANDLES_MEDIA_BUTTONS;
         holder.mSession.setFlags(holder.mFlags);
-        holder.mSession.addTransportControlsCallback(holder.mMediaButtonListener, mHandler);
-
-        holder.mMediaButtonReceiver = new MediaButtonReceiver(pi, context);
-        holder.mSession.addCallback(holder.mMediaButtonReceiver, mHandler);
         holder.mSession.setMediaButtonReceiver(pi);
+        holder.update();
         if (DEBUG) {
             Log.d(TAG, "addMediaButtonListener added " + pi);
         }
@@ -316,13 +310,10 @@
         }
         SessionHolder holder = getHolder(pi, false);
         if (holder != null && holder.mMediaButtonListener != null) {
-            holder.mSession.removeTransportControlsCallback(holder.mMediaButtonListener);
             holder.mFlags &= ~MediaSession.FLAG_HANDLES_MEDIA_BUTTONS;
             holder.mSession.setFlags(holder.mFlags);
             holder.mMediaButtonListener = null;
 
-            holder.mSession.removeCallback(holder.mMediaButtonReceiver);
-            holder.mMediaButtonReceiver = null;
             holder.update();
             if (DEBUG) {
                 Log.d(TAG, "removeMediaButtonListener removed " + pi);
@@ -387,22 +378,7 @@
         }
     }
 
-    private static final class MediaButtonReceiver extends MediaSession.Callback {
-        private final PendingIntent mPendingIntent;
-        private final Context mContext;
-
-        public MediaButtonReceiver(PendingIntent pi, Context context) {
-            mPendingIntent = pi;
-            mContext = context;
-        }
-
-        @Override
-        public void onMediaButtonEvent(Intent mediaButtonIntent) {
-            MediaSessionLegacyHelper.sendKeyEvent(mPendingIntent, mContext, mediaButtonIntent);
-        }
-    }
-
-    private static final class MediaButtonListener extends MediaSession.TransportControlsCallback {
+    private static final class MediaButtonListener extends MediaSession.Callback {
         private final PendingIntent mPendingIntent;
         private final Context mContext;
 
@@ -412,6 +388,12 @@
         }
 
         @Override
+        public boolean onMediaButtonEvent(Intent mediaButtonIntent) {
+            MediaSessionLegacyHelper.sendKeyEvent(mPendingIntent, mContext, mediaButtonIntent);
+            return true;
+        }
+
+        @Override
         public void onPlay() {
             sendKeyEvent(KeyEvent.KEYCODE_MEDIA_PLAY);
         }
@@ -468,10 +450,11 @@
         public final MediaSession mSession;
         public final PendingIntent mPi;
         public MediaButtonListener mMediaButtonListener;
-        public MediaButtonReceiver mMediaButtonReceiver;
-        public MediaSession.TransportControlsCallback mRccListener;
+        public MediaSession.Callback mRccListener;
         public int mFlags;
 
+        public SessionCallback mCb;
+
         public SessionHolder(MediaSession session, PendingIntent pi) {
             mSession = session;
             mPi = pi;
@@ -479,8 +462,87 @@
 
         public void update() {
             if (mMediaButtonListener == null && mRccListener == null) {
+                mSession.setCallback(null);
                 mSession.release();
+                mCb = null;
                 mSessions.remove(mPi);
+            } else if (mCb == null) {
+                mCb = new SessionCallback();
+                mSession.setCallback(mCb);
+            }
+        }
+
+        private class SessionCallback extends MediaSession.Callback {
+
+            @Override
+            public boolean onMediaButtonEvent(Intent mediaButtonIntent) {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onMediaButtonEvent(mediaButtonIntent);
+                }
+                return true;
+            }
+
+            @Override
+            public void onPlay() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onPlay();
+                }
+            }
+
+            @Override
+            public void onPause() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onPause();
+                }
+            }
+
+            @Override
+            public void onSkipToNext() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onSkipToNext();
+                }
+            }
+
+            @Override
+            public void onSkipToPrevious() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onSkipToPrevious();
+                }
+            }
+
+            @Override
+            public void onFastForward() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onFastForward();
+                }
+            }
+
+            @Override
+            public void onRewind() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onRewind();
+                }
+            }
+
+            @Override
+            public void onStop() {
+                if (mMediaButtonListener != null) {
+                    mMediaButtonListener.onStop();
+                }
+            }
+
+            @Override
+            public void onSeekTo(long pos) {
+                if (mRccListener != null) {
+                    mRccListener.onSeekTo(pos);
+                }
+            }
+
+            @Override
+            public void onSetRating(Rating rating) {
+                if (mRccListener != null) {
+                    mRccListener.onSetRating(rating);
+                }
             }
         }
     }
diff --git a/media/java/android/media/session/PlaybackState.java b/media/java/android/media/session/PlaybackState.java
index 65bd677..2ad8eae 100644
--- a/media/java/android/media/session/PlaybackState.java
+++ b/media/java/android/media/session/PlaybackState.java
@@ -845,20 +845,23 @@
         }
 
         /**
-         * Add a custom action to the playback state. Actions can be used to expose additional
-         * functionality to {@link MediaController MediaControllers} beyond what is offered by the
-         * standard transport controls.
+         * Add a custom action to the playback state. Actions can be used to
+         * expose additional functionality to {@link MediaController
+         * MediaControllers} beyond what is offered by the standard transport
+         * controls.
          * <p>
-         * e.g. start a radio station based on the current item or skip ahead by 30 seconds.
+         * e.g. start a radio station based on the current item or skip ahead by
+         * 30 seconds.
          *
-         * @param action An identifier for this action. It will be sent back to the
-         *               {@link MediaSession} through
-         *               {@link
-         *               MediaSession.TransportControlsCallback#onCustomAction(String, Bundle)}.
-         * @param name The display name for the action. If text is shown with the action or used
-         *             for accessibility, this is what should be used.
-         * @param icon The resource action of the icon that should be displayed for the action. The
-         *             resource should be in the package of the {@link MediaSession}.
+         * @param action An identifier for this action. It can be sent back to
+         *            the {@link MediaSession} through
+         *            {@link MediaController.TransportControls#sendCustomAction(String, Bundle)}.
+         * @param name The display name for the action. If text is shown with
+         *            the action or used for accessibility, this is what should
+         *            be used.
+         * @param icon The resource action of the icon that should be displayed
+         *            for the action. The resource should be in the package of
+         *            the {@link MediaSession}.
          * @return this
          */
         public Builder addCustomAction(String action, String name, int icon) {
diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java
index ae6f5bc..97a6b83 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -53,13 +53,25 @@
 
     private static final String PATH_CHANNEL = "channel";
     private static final String PATH_PROGRAM = "program";
-    private static final String PATH_INPUT = "input";
     private static final String PATH_PASSTHROUGH = "passthrough";
 
     /**
+     * An optional query, update or delete URI parameter that allows the caller to specify TV input
+     * ID to filter channels.
+     * @hide
+     */
+    public static final String PARAM_INPUT = "input";
+
+    /**
+     * An optional query, update or delete URI parameter that allows the caller to specify channel
+     * ID to filter programs.
+     * @hide
+     */
+    public static final String PARAM_CHANNEL = "channel";
+
+    /**
      * An optional query, update or delete URI parameter that allows the caller to specify start
      * time (in milliseconds since the epoch) to filter programs.
-     *
      * @hide
      */
     public static final String PARAM_START_TIME = "start_time";
@@ -67,7 +79,6 @@
     /**
      * An optional query, update or delete URI parameter that allows the caller to specify end time
      * (in milliseconds since the epoch) to filter programs.
-     *
      * @hide
      */
     public static final String PARAM_END_TIME = "end_time";
@@ -76,7 +87,6 @@
      * A query, update or delete URI parameter that allows the caller to operate on all or
      * browsable-only channels. If set to "true", the rows that contain non-browsable channels are
      * not affected.
-     *
      * @hide
      */
     public static final String PARAM_BROWSABLE_ONLY = "browsable_only";
@@ -84,7 +94,6 @@
     /**
      * A optional query, update or delete URI parameter that allows the caller to specify canonical
      * genre to filter programs.
-     *
      * @hide
      */
     public static final String PARAM_CANONICAL_GENRE = "canonical_genre";
@@ -116,17 +125,7 @@
      */
     public static final Uri buildChannelUriForPassthroughTvInput(String inputId) {
         return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
-                .appendPath(PATH_INPUT).appendPath(inputId).appendPath(PATH_CHANNEL)
-                .appendPath(PATH_PASSTHROUGH).build();
-    }
-
-    /**
-     * Returns true, if {@code channelUri} is a channel URI for a passthrough TV input.
-     * @hide
-     */
-    @SystemApi
-    public static final boolean isChannelUriForPassthroughTvInput(Uri channelUri) {
-        return channelUri.toString().endsWith(PATH_PASSTHROUGH);
+                .appendPath(PATH_PASSTHROUGH).appendPath(inputId).build();
     }
 
     /**
@@ -144,7 +143,7 @@
      * @param channelUri The URI of the channel whose logo is pointed to.
      */
     public static final Uri buildChannelLogoUri(Uri channelUri) {
-        if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) {
+        if (!isChannelUriForTunerTvInput(channelUri)) {
             throw new IllegalArgumentException("Not a channel: " + channelUri);
         }
         return Uri.withAppendedPath(channelUri, Channels.Logo.CONTENT_DIRECTORY);
@@ -169,8 +168,8 @@
      * @hide
      */
     public static final Uri buildChannelsUriForInput(String inputId, boolean browsableOnly) {
-        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
-                .appendPath(PATH_INPUT).appendPath(inputId).appendPath(PATH_CHANNEL)
+        return Channels.CONTENT_URI.buildUpon()
+                .appendQueryParameter(PARAM_INPUT, inputId)
                 .appendQueryParameter(PARAM_BROWSABLE_ONLY, String.valueOf(browsableOnly)).build();
     }
 
@@ -194,8 +193,7 @@
 
         Uri uri;
         if (inputId == null) {
-            uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
-                    .appendPath(PATH_CHANNEL).build();
+            uri = Channels.CONTENT_URI;
         } else {
             uri = buildChannelsUriForInput(inputId, browsableOnly);
         }
@@ -217,9 +215,8 @@
      * @param channelId The ID of the channel to return programs for.
      */
     public static final Uri buildProgramsUriForChannel(long channelId) {
-        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
-                .appendPath(PATH_CHANNEL).appendPath(String.valueOf(channelId))
-                .appendPath(PATH_PROGRAM).build();
+        return Programs.CONTENT_URI.buildUpon()
+                .appendQueryParameter(PARAM_CHANNEL, String.valueOf(channelId)).build();
     }
 
     /**
@@ -228,7 +225,7 @@
      * @param channelUri The URI of the channel to return programs for.
      */
     public static final Uri buildProgramsUriForChannel(Uri channelUri) {
-        if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) {
+        if (!isChannelUriForTunerTvInput(channelUri)) {
             throw new IllegalArgumentException("Not a channel: " + channelUri);
         }
         return buildProgramsUriForChannel(ContentUris.parseId(channelUri));
@@ -263,7 +260,7 @@
      */
     public static final Uri buildProgramsUriForChannel(Uri channelUri, long startTime,
             long endTime) {
-        if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) {
+        if (!isChannelUriForTunerTvInput(channelUri)) {
             throw new IllegalArgumentException("Not a channel: " + channelUri);
         }
         return buildProgramsUriForChannel(ContentUris.parseId(channelUri), startTime, endTime);
@@ -279,41 +276,47 @@
         return ContentUris.withAppendedId(WatchedPrograms.CONTENT_URI, watchedProgramId);
     }
 
-    /**
-     * Extracts the {@link Channels#COLUMN_INPUT_ID} from a given URI.
-     *
-     * @param channelsUri A URI constructed by {@link #buildChannelsUriForInput(String)},
-     *            {@link #buildChannelsUriForInput(String, boolean)}, or
-     *            {@link #buildChannelsUriForCanonicalGenre(String, String, boolean)}.
-     * @hide
-     */
-    public static final String getInputId(Uri channelsUri) {
-        final List<String> paths = channelsUri.getPathSegments();
-        if (paths.size() < 3) {
-            throw new IllegalArgumentException("Not channels: " + channelsUri);
-        }
-        if (!PATH_INPUT.equals(paths.get(0)) || !PATH_CHANNEL.equals(paths.get(2))) {
-            throw new IllegalArgumentException("Not channels: " + channelsUri);
-        }
-        return paths.get(1);
+    private static final boolean isTvUri(Uri uri) {
+        return uri != null && ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())
+                && AUTHORITY.equals(uri.getAuthority());
+    }
+
+    private static final boolean isTwoSegmentUriStartingWith(Uri uri, String pathSegment) {
+        List<String> pathSegments = uri.getPathSegments();
+        return pathSegments.size() == 2 && pathSegment.equals(pathSegments.get(0));
     }
 
     /**
-     * Extracts the {@link Channels#_ID} from a given URI.
-     *
-     * @param programsUri A URI constructed by {@link #buildProgramsUriForChannel(Uri)} or
-     *            {@link #buildProgramsUriForChannel(Uri, long, long)}.
+     * Returns true, if {@code uri} is a channel URI.
      * @hide
      */
-    public static final String getChannelId(Uri programsUri) {
-        final List<String> paths = programsUri.getPathSegments();
-        if (paths.size() < 3) {
-            throw new IllegalArgumentException("Not programs: " + programsUri);
-        }
-        if (!PATH_CHANNEL.equals(paths.get(0)) || !PATH_PROGRAM.equals(paths.get(2))) {
-            throw new IllegalArgumentException("Not programs: " + programsUri);
-        }
-        return paths.get(1);
+    public static final boolean isChannelUri(Uri uri) {
+        return isChannelUriForTunerTvInput(uri) || isChannelUriForPassthroughTvInput(uri);
+    }
+
+    /**
+     * Returns true, if {@code uri} is a channel URI for a tuner TV input.
+     * @hide
+     */
+    public static final boolean isChannelUriForTunerTvInput(Uri uri) {
+        return isTvUri(uri) && isTwoSegmentUriStartingWith(uri, PATH_CHANNEL);
+    }
+
+    /**
+     * Returns true, if {@code uri} is a channel URI for a passthrough TV input.
+     * @hide
+     */
+    @SystemApi
+    public static final boolean isChannelUriForPassthroughTvInput(Uri uri) {
+        return isTvUri(uri) && isTwoSegmentUriStartingWith(uri, PATH_PASSTHROUGH);
+    }
+
+    /**
+     * Returns true, if {@code uri} is a program URI.
+     * @hide
+     */
+    public static final boolean isProgramUri(Uri uri) {
+        return isTvUri(uri) && isTwoSegmentUriStartingWith(uri, PATH_PROGRAM);
     }
 
 
@@ -1104,7 +1107,6 @@
     /**
      * Column definitions for the TV programs that the user watched. Applications do not have access
      * to this table.
-     *
      * @hide
      */
     public static final class WatchedPrograms implements BaseTvColumns {
diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java
index 8d0e986..94e9b41 100644
--- a/media/java/android/media/tv/TvInputInfo.java
+++ b/media/java/android/media/tv/TvInputInfo.java
@@ -33,9 +33,12 @@
 import android.net.Uri;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.os.UserHandle;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.util.Pair;
 import android.util.SparseIntArray;
 import android.util.Xml;
 
@@ -44,6 +47,9 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * This class is used to specify meta information of a TV input.
@@ -390,7 +396,20 @@
     }
 
     /**
-     * Loads the user-displayed label for this TV input service.
+     * Checks if this TV input is marked hidden by the user in the settings.
+     *
+     * @param context Supplies a {@link Context} used to check if this TV input is hidden.
+     * @return {@code true} if the user marked this TV input hidden in settings. {@code false}
+     *         otherwise.
+     * @hide
+     */
+    @SystemApi
+    public boolean isHidden(Context context) {
+        return TvInputSettings.isHidden(context, mId, UserHandle.USER_CURRENT);
+    }
+
+    /**
+     * Loads the user-displayed label for this TV input.
      *
      * @param context Supplies a {@link Context} used to load the label.
      * @return a CharSequence containing the TV input's label. If the TV input does not have
@@ -405,7 +424,20 @@
     }
 
     /**
-     * Loads the user-displayed icon for this TV input service.
+     * Loads the custom label set by user in settings.
+     *
+     * @param context Supplies a {@link Context} used to load the custom label.
+     * @return a CharSequence containing the TV input's custom label. {@code null} if there is no
+     *         custom label.
+     * @hide
+     */
+    @SystemApi
+    public CharSequence loadCustomLabel(Context context) {
+        return TvInputSettings.getCustomLabel(context, mId, UserHandle.USER_CURRENT);
+    }
+
+    /**
+     * Loads the user-displayed icon for this TV input.
      *
      * @param context Supplies a {@link Context} used to load the icon.
      * @return a Drawable containing the TV input's icon. If the TV input does not have
@@ -551,4 +583,139 @@
         mIsConnectedToHdmiSwitch = in.readByte() == 1 ? true : false;
         mRatingSystemXmlUri = in.readParcelable(null);
     }
+
+    /**
+     * Utility class for putting and getting settings for TV input.
+     *
+     * @hide
+     */
+    @SystemApi
+    public static final class TvInputSettings {
+        private static final String TV_INPUT_SEPARATOR = ":";
+        private static final String CUSTOM_NAME_SEPARATOR = ",";
+
+        private TvInputSettings() { }
+
+        private static boolean isHidden(Context context, String inputId, int userId) {
+            return getHiddenTvInputIds(context, userId).contains(inputId);
+        }
+
+        private static String getCustomLabel(Context context, String inputId, int userId) {
+            for (Pair<String, String> pair : getCustomLabelList(context, userId)) {
+                if (pair.first.equals(inputId)) {
+                    return pair.second;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * Returns a list of TV input IDs which are marked as hidden by user in the settings.
+         *
+         * @param context The application context
+         * @param userId The user ID for the stored hidden input list
+         * @hide
+         */
+        @SystemApi
+        public static List<String> getHiddenTvInputIds(Context context, int userId) {
+            String hiddenIdsString = Settings.Secure.getStringForUser(
+                    context.getContentResolver(), Settings.Secure.TV_INPUT_HIDDEN_INPUTS, userId);
+            if (TextUtils.isEmpty(hiddenIdsString)) {
+                return new ArrayList<String>();
+            }
+            String[] ids = hiddenIdsString.split(TV_INPUT_SEPARATOR);
+            return Arrays.asList(ids);
+        }
+
+        /**
+         * Returns a list of TV input ID/custom label pairs set by the user in the settings.
+         *
+         * @param context The application context
+         * @param userId The user ID for the stored hidden input list
+         * @hide
+         */
+        @SystemApi
+        public static List<Pair<String, String>> getCustomLabelList(Context context, int userId) {
+            String labelsString = Settings.Secure.getStringForUser(
+                    context.getContentResolver(), Settings.Secure.TV_INPUT_CUSTOM_LABELS, userId);
+            List<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
+            if (TextUtils.isEmpty(labelsString)) {
+                return list;
+            }
+            String[] pairs = labelsString.split(TV_INPUT_SEPARATOR);
+            for (String pairString : pairs) {
+                String[] pair = pairString.split(CUSTOM_NAME_SEPARATOR);
+                list.add(new Pair<String, String>(pair[0], pair[1]));
+            }
+            return list;
+        }
+
+        /**
+         * Stores a list of TV input IDs which are marked as hidden by user. This is expected to
+         * be called from the settings app.
+         *
+         * @param context The application context
+         * @param hiddenInputIds A list including all the hidden TV input IDs
+         * @param userId The user ID for the stored hidden input list
+         * @hide
+         */
+        @SystemApi
+        public static void putHiddenTvInputList(Context context, List<String> hiddenInputIds,
+                int userId) {
+            StringBuilder builder = new StringBuilder();
+            boolean firstItem = true;
+            for (String inputId : hiddenInputIds) {
+                ensureSeparatorIsNotIncluded(inputId);
+                if (firstItem) {
+                    firstItem = false;
+                } else {
+                    builder.append(TV_INPUT_SEPARATOR);
+                }
+                builder.append(inputId);
+            }
+            Settings.Secure.putStringForUser(context.getContentResolver(),
+                    Settings.Secure.TV_INPUT_HIDDEN_INPUTS, builder.toString(), userId);
+        }
+
+        /**
+         * Stores a list of TV input ID/custom label pairs set by user. This is expected to be
+         * called from the settings app.
+         *
+         * @param context The application context.
+         * @param customLabels A list of TV input ID/custom label pairs
+         * @param userId The user ID for the stored hidden input list
+         * @hide
+         */
+        @SystemApi
+        public static void putCustomLabelList(Context context,
+                List<Pair<String, String>> customLabels, int userId) {
+            StringBuilder builder = new StringBuilder();
+            boolean firstItem = true;
+            for (Pair<String, String> pair : customLabels) {
+                ensureSeparatorIsNotIncluded(pair.first);
+                ensureSeparatorIsNotIncluded(pair.second);
+                if (firstItem) {
+                    firstItem = false;
+                } else {
+                    builder.append(TV_INPUT_SEPARATOR);
+                }
+                builder.append(pair.first);
+                builder.append(CUSTOM_NAME_SEPARATOR);
+                builder.append(pair.second);
+            }
+            Settings.Secure.putStringForUser(context.getContentResolver(),
+                    Settings.Secure.TV_INPUT_CUSTOM_LABELS, builder.toString(), userId);
+        }
+
+        private static void ensureSeparatorIsNotIncluded(String value) {
+            if (value.contains(TV_INPUT_SEPARATOR)) {
+                throw new IllegalArgumentException( value + " should not include "
+                        + TV_INPUT_SEPARATOR);
+            }
+            if (value.contains(CUSTOM_NAME_SEPARATOR)) {
+                throw new IllegalArgumentException( value + " should not include "
+                        + CUSTOM_NAME_SEPARATOR);
+            }
+        }
+    }
 }
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 408ee7b..8783648 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -1057,6 +1057,7 @@
         private TvInputManager.Session mHardwareSession;
         private ITvInputSession mProxySession;
         private ITvInputSessionCallback mProxySessionCallback;
+        private Handler mServiceHandler;
 
         /**
          * Returns the hardware TV input ID the external device is connected to.
@@ -1085,7 +1086,7 @@
                     args.arg3 = null;
                     onRelease();
                 }
-                mHandler.obtainMessage(ServiceHandler.DO_NOTIFY_SESSION_CREATED, args)
+                mServiceHandler.obtainMessage(ServiceHandler.DO_NOTIFY_SESSION_CREATED, args)
                         .sendToTarget();
             }
 
@@ -1209,8 +1210,8 @@
                     InputChannel channel = (InputChannel) args.arg1;
                     ITvInputSessionCallback cb = (ITvInputSessionCallback) args.arg2;
                     String inputId = (String) args.arg3;
-                    Session sessionImpl = onCreateSession(inputId);
                     args.recycle();
+                    Session sessionImpl = onCreateSession(inputId);
                     if (sessionImpl == null) {
                         try {
                             // Failed to create a session.
@@ -1218,39 +1219,40 @@
                         } catch (RemoteException e) {
                             Log.e(TAG, "error in onSessionCreated");
                         }
-                    } else {
-                        sessionImpl.setSessionCallback(cb);
-                        ITvInputSession stub = new ITvInputSessionWrapper(TvInputService.this,
-                                sessionImpl, channel);
-                        if (sessionImpl instanceof HardwareSession) {
-                            HardwareSession proxySession =
-                                    ((HardwareSession) sessionImpl);
-                            String harewareInputId = proxySession.getHardwareInputId();
-                            if (!TextUtils.isEmpty(harewareInputId)) {
-                                // TODO: check if the given ID is really hardware TV input.
-                                proxySession.mProxySession = stub;
-                                proxySession.mProxySessionCallback = cb;
-                                TvInputManager manager = (TvInputManager) getSystemService(
-                                        Context.TV_INPUT_SERVICE);
-                                manager.createSession(harewareInputId,
-                                        proxySession.mHardwareSessionCallback, mServiceHandler);
-                            } else {
-                                sessionImpl.onRelease();
-                                Log.w(TAG, "Hardware input id is not setup yet.");
-                                try {
-                                    cb.onSessionCreated(null, null);
-                                } catch (RemoteException e) {
-                                    Log.e(TAG, "error in onSessionCreated");
-                                }
+                        return;
+                    }
+                    sessionImpl.setSessionCallback(cb);
+                    ITvInputSession stub = new ITvInputSessionWrapper(TvInputService.this,
+                            sessionImpl, channel);
+                    if (sessionImpl instanceof HardwareSession) {
+                        HardwareSession proxySession =
+                                ((HardwareSession) sessionImpl);
+                        String harewareInputId = proxySession.getHardwareInputId();
+                        if (TextUtils.isEmpty(harewareInputId)) {
+                            sessionImpl.onRelease();
+                            Log.w(TAG, "Hardware input id is not setup yet.");
+                            try {
+                                cb.onSessionCreated(null, null);
+                            } catch (RemoteException e) {
+                                Log.e(TAG, "error in onSessionCreated");
                             }
-                        } else {
-                            SomeArgs someArgs = SomeArgs.obtain();
-                            someArgs.arg1 = stub;
-                            someArgs.arg2 = cb;
-                            someArgs.arg3 = null;
-                            mServiceHandler.obtainMessage(ServiceHandler.DO_NOTIFY_SESSION_CREATED,
-                                    someArgs).sendToTarget();
+                            return;
                         }
+                        // TODO: check if the given ID is really hardware TV input.
+                        proxySession.mProxySession = stub;
+                        proxySession.mProxySessionCallback = cb;
+                        proxySession.mServiceHandler = mServiceHandler;
+                        TvInputManager manager = (TvInputManager) getSystemService(
+                                Context.TV_INPUT_SERVICE);
+                        manager.createSession(harewareInputId,
+                                proxySession.mHardwareSessionCallback, mServiceHandler);
+                    } else {
+                        SomeArgs someArgs = SomeArgs.obtain();
+                        someArgs.arg1 = stub;
+                        someArgs.arg2 = cb;
+                        someArgs.arg3 = null;
+                        mServiceHandler.obtainMessage(ServiceHandler.DO_NOTIFY_SESSION_CREATED,
+                                someArgs).sendToTarget();
                     }
                     return;
                 }
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index 4315e0d..609ffda 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -121,8 +121,6 @@
 
     private static final int LOADED_PROFILE_ID = -1;
 
-    private static final int DISABLED_PROFILE = -1;
-
     private static final int UNKNOWN_USER_ID = -10;
 
     // Bump if the stored widgets need to be upgraded.
@@ -660,7 +658,8 @@
     }
 
     @Override
-    public IntentSender createAppWidgetConfigIntentSender(String callingPackage, Intent intent) {
+    public IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId,
+            int intentFlags) {
         final int userId = UserHandle.getCallingUserId();
 
         if (DEBUG) {
@@ -670,57 +669,6 @@
         // Make sure the package runs under the caller uid.
         mSecurityPolicy.enforceCallFromPackage(callingPackage);
 
-        // The only allowed action is the one to start the configure activity.
-        if (!AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(intent.getAction())) {
-            throw new IllegalArgumentException("Only allowed action is "
-                    + AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
-        }
-
-        // Verify that widget id is provided.
-        final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
-                AppWidgetManager.INVALID_APPWIDGET_ID);
-        if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
-            throw new IllegalArgumentException("Widget id required");
-        }
-
-        // Make sure a component name is provided.
-        ComponentName component = intent.getComponent();
-        if (component == null) {
-            throw new IllegalArgumentException("Component name required");
-        }
-
-        // Verify the user handle.
-        UserHandle userHandle = intent.getParcelableExtra(
-                AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
-        if (userHandle != null) {
-            // Remove the profile extra as the receiver already runs under this
-            // user and this information is of no use to this receiver.
-            intent.removeExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
-
-            // If the user handle is not the caller, check if it is an enabled
-            // profile for which the package is white-listed.
-            final int profileId = userHandle.getIdentifier();
-            if (profileId != userId) {
-                // Make sure the passed user handle is a profile in the group.
-                final int[] profileIds = mSecurityPolicy.resolveCallerEnabledGroupProfiles(
-                        new int[]{profileId});
-                if (profileIds.length <= 0) {
-                    // The profile is not in the group or not enabled, done.
-                    return null;
-                }
-
-                // Make sure the provider is white-listed.
-                if (!mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(
-                        component.getPackageName(), profileId)) {
-                    throw new IllegalArgumentException("Cannot access provider "
-                            + component + " in user " + profileIds);
-                }
-            }
-        } else {
-            // If a profile is not specified use the caller user id.
-            userHandle = new UserHandle(userId);
-        }
-
         synchronized (mLock) {
             ensureGroupStateLoadedLocked(userId);
 
@@ -738,19 +686,18 @@
                 throw new IllegalArgumentException("Widget not bound " + appWidgetId);
             }
 
-            // Make sure the component refers to the provider config activity.
-            if (!component.equals(provider.info.configure)
-                    || !provider.info.getProfile().equals(userHandle)) {
-                throw new IllegalArgumentException("No component" + component
-                        + " for user " + userHandle.getIdentifier());
-            }
+            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
+            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+            intent.setComponent(provider.info.configure);
+            intent.setFlags(intentFlags);
 
             // All right, create the sender.
             final long identity = Binder.clearCallingIdentity();
             try {
                 return PendingIntent.getActivityAsUser(
                         mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT
-                                | PendingIntent.FLAG_CANCEL_CURRENT, null, userHandle)
+                                | PendingIntent.FLAG_CANCEL_CURRENT, null,
+                                new UserHandle(provider.getUserId()))
                         .getIntentSender();
             } finally {
                 Binder.restoreCallingIdentity(identity);
@@ -771,9 +718,7 @@
         mSecurityPolicy.enforceCallFromPackage(callingPackage);
 
         // Check that if a cross-profile binding is attempted, it is allowed.
-        final int[] profileIds = mSecurityPolicy.resolveCallerEnabledGroupProfiles(
-                new int[] {providerProfileId});
-        if (profileIds.length <= 0) {
+        if (!mSecurityPolicy.isEnabledGroupProfile(providerProfileId)) {
             return false;
         }
 
@@ -1309,28 +1254,23 @@
     }
 
     @Override
-    public List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter, int[] profileIds) {
+    public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter,
+            int profileId) {
         final int userId = UserHandle.getCallingUserId();
 
         if (DEBUG) {
             Slog.i(TAG, "getInstalledProvidersForProfiles() " + userId);
         }
 
-        if (profileIds != null && profileIds.length > 0) {
-            // Make sure the profile ids are children of the calling user.
-            profileIds = mSecurityPolicy.resolveCallerEnabledGroupProfiles(profileIds);
-        } else {
-            profileIds = new int[] {userId};
-        }
-
-        if (profileIds.length == 0) {
+        // Ensure the profile is in the group and enabled.
+        if (!mSecurityPolicy.isEnabledGroupProfile(profileId)) {
             return null;
         }
 
         synchronized (mLock) {
             ensureGroupStateLoadedLocked(userId);
 
-            ArrayList<AppWidgetProviderInfo> result = new ArrayList<>();
+            ArrayList<AppWidgetProviderInfo> result = null;
 
             final int providerCount = mProviders.size();
             for (int i = 0; i < providerCount; i++) {
@@ -1342,19 +1282,15 @@
                     continue;
                 }
 
-                // Add providers only for the requested profiles ...
+                // Add providers only for the requested profile that are white-listed.
                 final int providerProfileId = info.getProfile().getIdentifier();
-                final int profileCount = profileIds.length;
-                for (int j = 0; j < profileCount; j++) {
-                    final int profileId = profileIds[j];
-                    if (providerProfileId == profileId) {
-                        // ... that are white-listed by the profile manager.
-                        if (mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(
-                                provider.id.componentName.getPackageName(), providerProfileId)) {
-                            result.add(cloneIfLocalBinder(info));
-                        }
-                        break;
+                if (providerProfileId == profileId
+                        && mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(
+                            provider.id.componentName.getPackageName(), providerProfileId)) {
+                    if (result == null) {
+                        result = new ArrayList<>();
                     }
+                    result.add(cloneIfLocalBinder(info));
                 }
             }
 
@@ -2967,35 +2903,9 @@
 
     private final class SecurityPolicy {
 
-        public int[] resolveCallerEnabledGroupProfiles(int[] profileIds) {
+        public boolean isEnabledGroupProfile(int profileId) {
             final int parentId = UserHandle.getCallingUserId();
-
-            int enabledProfileCount = 0;
-            final int profileCount = profileIds.length;
-            for (int i = 0; i < profileCount; i++) {
-                final int profileId = profileIds[i];
-                if (!isParentOrProfile(parentId, profileId)) {
-                    throw new SecurityException("Not the current user or"
-                            + " a child profile: " + profileId);
-                }
-                if (!isProfileEnabled(profileId)) {
-                    profileIds[i] = DISABLED_PROFILE;
-                } else {
-                    enabledProfileCount++;
-                }
-            }
-
-            int resolvedProfileIndex = 0;
-            final int[] resolvedProfiles = new int[enabledProfileCount];
-            for (int i = 0; i < profileCount; i++) {
-                final int profileId = profileIds[i];
-                if (profileId != DISABLED_PROFILE) {
-                    resolvedProfiles[resolvedProfileIndex] = profileId;
-                    resolvedProfileIndex++;
-                }
-            }
-
-            return resolvedProfiles;
+            return isParentOrProfile(parentId, profileId) && isProfileEnabled(profileId);
         }
 
         public int[] getEnabledGroupProfileIds(int userId) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c7c7a92..d3421fd 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8971,8 +8971,10 @@
     }
 
     /**
-     * Allows app to retrieve the MIME type of a URI without having permission
-     * to access its content provider.
+     * Allows apps to retrieve the MIME type of a URI.
+     * If an app is in the same user as the ContentProvider, or if it is allowed to interact across
+     * users, then it does not need permission to access the ContentProvider.
+     * Either, it needs cross-user uri grants.
      *
      * CTS tests for this functionality can be run with "runtest cts-appsecurity".
      *
@@ -8981,12 +8983,22 @@
      */
     public String getProviderMimeType(Uri uri, int userId) {
         enforceNotIsolatedCaller("getProviderMimeType");
-        userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
-                userId, false, ALLOW_NON_FULL_IN_PROFILE, "getProviderMimeType", null);
         final String name = uri.getAuthority();
-        final long ident = Binder.clearCallingIdentity();
+        int callingUid = Binder.getCallingUid();
+        int callingPid = Binder.getCallingPid();
+        long ident = 0;
+        boolean clearedIdentity = false;
+        userId = unsafeConvertIncomingUser(userId);
+        if (UserHandle.getUserId(callingUid) != userId) {
+            if (checkComponentPermission(INTERACT_ACROSS_USERS, callingPid,
+                    callingUid, -1, true) == PackageManager.PERMISSION_GRANTED
+                    || checkComponentPermission(INTERACT_ACROSS_USERS_FULL, callingPid,
+                    callingUid, -1, true) == PackageManager.PERMISSION_GRANTED) {
+                clearedIdentity = true;
+                ident = Binder.clearCallingIdentity();
+            }
+        }
         ContentProviderHolder holder = null;
-
         try {
             holder = getContentProviderExternalUnchecked(name, null, userId);
             if (holder != null) {
@@ -8996,10 +9008,17 @@
             Log.w(TAG, "Content provider dead retrieving " + uri, e);
             return null;
         } finally {
-            if (holder != null) {
-                removeContentProviderExternalUnchecked(name, null, userId);
+            // We need to clear the identity to call removeContentProviderExternalUnchecked
+            if (!clearedIdentity) {
+                ident = Binder.clearCallingIdentity();
             }
-            Binder.restoreCallingIdentity(ident);
+            try {
+                if (holder != null) {
+                    removeContentProviderExternalUnchecked(name, null, userId);
+                }
+            } finally {
+                Binder.restoreCallingIdentity(ident);
+            }
         }
 
         return null;
@@ -17335,11 +17354,6 @@
 
                 if ((userInfo.flags&UserInfo.FLAG_INITIALIZED) == 0) {
                     if (userId != UserHandle.USER_OWNER) {
-                        // Send PRE_BOOT_COMPLETED broadcasts for this new user
-                        final ArrayList<ComponentName> doneReceivers
-                                = new ArrayList<ComponentName>();
-                        deliverPreBootCompleted(null, doneReceivers, userId);
-
                         Intent intent = new Intent(Intent.ACTION_USER_INITIALIZE);
                         intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                         broadcastIntentLocked(null, null, intent, null,
diff --git a/services/core/java/com/android/server/hdmi/Constants.java b/services/core/java/com/android/server/hdmi/Constants.java
index 0b57474..0003210 100644
--- a/services/core/java/com/android/server/hdmi/Constants.java
+++ b/services/core/java/com/android/server/hdmi/Constants.java
@@ -214,5 +214,35 @@
     static final int RECORDING_TYPE_EXTERNAL_PHYSICAL_ADDRESS = 3;
     static final int RECORDING_TYPE_OWN_SOURCE = 4;
 
+    // Definitions used for setOption(). These should be in sync with the definition
+    // in hardware/libhardware/include/hardware/{hdmi_cec.h,mhl.h}.
+
+    // TV gets turned on by incoming <Text/Image View On>. enabled by default.
+    // If set to disabled, TV won't turn on automatically.
+    static final int OPTION_CEC_AUTO_WAKEUP = 1;
+
+    // If set to disabled, all CEC commands are discarded.
+    static final int OPTION_CEC_ENABLE = 2;
+
+    // If set to disabled, system service yields control of CEC to sub-microcontroller.
+    // If enabled, it take the control back.
+    static final int OPTION_CEC_SERVICE_CONTROL = 3;
+
+    // Put other devices to standby when TV goes to standby. enabled by default.
+    // If set to disabled, TV doesn't send <Standby> to other devices.
+    static final int OPTION_CEC_AUTO_DEVICE_OFF = 4;
+
+    // If set to disabled, TV does not switch ports when mobile device is connected.
+    static final int OPTION_MHL_INPUT_SWITCHING = 101;
+
+    // If set to enabled, TV disables power charging for mobile device.
+    static final int OPTION_MHL_POWER_CHARGE = 102;
+
+    // If set to disabled, all MHL commands are discarded.
+    static final int OPTION_MHL_ENABLE = 103;
+
+    static final int DISABLED = 0;
+    static final int ENABLED = 1;
+
     private Constants() { /* cannot be instantiated */ }
 }
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index ad5b2ba..183f299 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -30,8 +30,8 @@
 import static android.hardware.hdmi.HdmiControlManager.TIMER_RECORDING_TYPE_EXTERNAL;
 
 import android.content.Intent;
-import android.hardware.hdmi.HdmiDeviceInfo;
 import android.hardware.hdmi.HdmiControlManager;
+import android.hardware.hdmi.HdmiDeviceInfo;
 import android.hardware.hdmi.HdmiRecordSources;
 import android.hardware.hdmi.HdmiTimerRecordSources;
 import android.hardware.hdmi.IHdmiControlCallback;
@@ -1274,14 +1274,12 @@
     void setAutoDeviceOff(boolean enabled) {
         assertRunOnServiceThread();
         mAutoDeviceOff = enabled;
-        mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, enabled);
     }
 
     @ServiceThreadOnly
     void setAutoWakeup(boolean enabled) {
         assertRunOnServiceThread();
         mAutoWakeup = enabled;
-        mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, enabled);
     }
 
     @ServiceThreadOnly
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index 81b99f0..6f68bd8 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -16,17 +16,27 @@
 
 package com.android.server.hdmi;
 
+import static com.android.server.hdmi.Constants.DISABLED;
+import static com.android.server.hdmi.Constants.ENABLED;
+import static com.android.server.hdmi.Constants.OPTION_CEC_AUTO_DEVICE_OFF;
+import static com.android.server.hdmi.Constants.OPTION_CEC_AUTO_WAKEUP;
+import static com.android.server.hdmi.Constants.OPTION_CEC_ENABLE;
+import static com.android.server.hdmi.Constants.OPTION_CEC_SERVICE_CONTROL;
+import static com.android.server.hdmi.Constants.OPTION_MHL_ENABLE;
+import static com.android.server.hdmi.Constants.OPTION_MHL_INPUT_SWITCHING;
+import static com.android.server.hdmi.Constants.OPTION_MHL_POWER_CHARGE;
+
 import android.annotation.Nullable;
 import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.database.ContentObserver;
 import android.hardware.hdmi.HdmiDeviceInfo;
 import android.hardware.hdmi.HdmiControlManager;
 import android.hardware.hdmi.HdmiHotplugEvent;
 import android.hardware.hdmi.HdmiPortInfo;
-import android.hardware.hdmi.HdmiTvClient;
 import android.hardware.hdmi.IHdmiControlCallback;
 import android.hardware.hdmi.IHdmiControlService;
 import android.hardware.hdmi.IHdmiDeviceEventListener;
@@ -36,6 +46,7 @@
 import android.hardware.hdmi.IHdmiSystemAudioModeChangeListener;
 import android.hardware.hdmi.IHdmiVendorCommandListener;
 import android.media.AudioManager;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Handler;
 import android.os.HandlerThread;
@@ -44,6 +55,7 @@
 import android.os.PowerManager;
 import android.os.RemoteException;
 import android.os.SystemClock;
+import android.os.UserHandle;
 import android.provider.Settings.Global;
 import android.util.ArraySet;
 import android.util.Slog;
@@ -196,6 +208,8 @@
     // Handler used to run a task in service thread.
     private final Handler mHandler = new Handler();
 
+    private final SettingsObserver mSettingsObserver;
+
     @Nullable
     private HdmiCecController mCecController;
 
@@ -229,6 +243,7 @@
         super(context);
         mLocalDevices = HdmiUtils.asImmutableList(getContext().getResources().getIntArray(
                 com.android.internal.R.array.config_hdmiCecLogicalDeviceType));
+        mSettingsObserver = new SettingsObserver(mHandler);
     }
 
     @Override
@@ -241,8 +256,7 @@
         mCecController = HdmiCecController.create(this);
         if (mCecController != null) {
             // TODO: Remove this as soon as OEM's HAL implementation is corrected.
-            mCecController.setOption(HdmiTvClient.OPTION_CEC_ENABLE,
-                    HdmiTvClient.ENABLED);
+            mCecController.setOption(OPTION_CEC_ENABLE, ENABLED);
 
             // TODO: load value for mHdmiControlEnabled from preference.
             if (mHdmiControlEnabled) {
@@ -279,24 +293,78 @@
         mWakeUpMessageReceived = false;
 
         if (isTvDevice()) {
-            mCecController.setOption(HdmiTvClient.OPTION_CEC_AUTO_WAKEUP,
-                    tv().getAutoWakeup() ? HdmiTvClient.ENABLED : HdmiTvClient.DISABLED);
+            mCecController.setOption(OPTION_CEC_AUTO_WAKEUP, toInt(tv().getAutoWakeup()));
+            registerContentObserver();
         }
     }
 
+
+    private void registerContentObserver() {
+        ContentResolver resolver = getContext().getContentResolver();
+        String[] settings = new String[] {
+                Global.HDMI_CONTROL_ENABLED,
+                Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED,
+                Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
+                Global.MHL_INPUT_SWITCHING_ENABLED,
+                Global.MHL_POWER_CHARGE_ENABLED
+        };
+        for (String s: settings) {
+            resolver.registerContentObserver(Global.getUriFor(s), false, mSettingsObserver,
+                    UserHandle.USER_ALL);
+        }
+    }
+
+    private class SettingsObserver extends ContentObserver {
+        public SettingsObserver(Handler handler) {
+            super(handler);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri) {
+            String option = uri.getLastPathSegment();
+            boolean enabled = readBooleanSetting(option, true);
+            switch (option) {
+                case Global.HDMI_CONTROL_ENABLED:
+                    setControlEnabled(enabled);
+                    break;
+                case Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED:
+                    tv().setAutoWakeup(enabled);
+                    setOption(OPTION_CEC_AUTO_WAKEUP, toInt(enabled));
+                    break;
+                case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED:
+                    tv().setAutoDeviceOff(enabled);
+                    // No need to propagate to HAL.
+                    break;
+                case Global.MHL_INPUT_SWITCHING_ENABLED:
+                    setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled));
+                    break;
+                case Global.MHL_POWER_CHARGE_ENABLED:
+                    setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled));
+                    break;
+            }
+        }
+    }
+
+    private static int toInt(boolean enabled) {
+        return enabled ? ENABLED : DISABLED;
+    }
+
     boolean readBooleanSetting(String key, boolean defVal) {
         ContentResolver cr = getContext().getContentResolver();
-        return Global.getInt(cr, key, defVal ? Constants.TRUE : Constants.FALSE) == Constants.TRUE;
+        return Global.getInt(cr, key, toInt(defVal)) == ENABLED;
     }
 
     void writeBooleanSetting(String key, boolean value) {
         ContentResolver cr = getContext().getContentResolver();
-        Global.putInt(cr, key, value ? Constants.TRUE : Constants.FALSE);
+        Global.putInt(cr, key, toInt(value));
+    }
+
+    private void unregisterSettingsObserver() {
+        getContext().getContentResolver().unregisterContentObserver(mSettingsObserver);
     }
 
     private void initializeCec(int initiatedBy) {
-        mCecController.setOption(HdmiTvClient.OPTION_CEC_SERVICE_CONTROL,
-                HdmiTvClient.ENABLED);
+        mCecController.setOption(OPTION_CEC_SERVICE_CONTROL, ENABLED);
         initializeLocalDevices(mLocalDevices, initiatedBy);
     }
 
@@ -965,18 +1033,6 @@
         }
 
         @Override
-        public void setControlEnabled(final boolean enabled) {
-            enforceAccessPermission();
-            runOnServiceThread(new Runnable() {
-                @Override
-                public void run() {
-                    handleHdmiControlStatusChanged(enabled);
-
-                }
-            });
-        }
-
-        @Override
         public void setSystemAudioVolume(final int oldIndex, final int newIndex,
                 final int maxIndex) {
             enforceAccessPermission();
@@ -1025,30 +1081,6 @@
         }
 
         @Override
-        public void setOption(final int key, final int value) {
-            enforceAccessPermission();
-            if (!isTvDevice()) {
-                return;
-            }
-            switch (key) {
-                case HdmiTvClient.OPTION_CEC_AUTO_WAKEUP:
-                    tv().setAutoWakeup(value == HdmiTvClient.ENABLED);
-                    mCecController.setOption(key, value);
-                    break;
-                case HdmiTvClient.OPTION_CEC_AUTO_DEVICE_OFF:
-                    // No need to pass this option to HAL.
-                    tv().setAutoDeviceOff(value == HdmiTvClient.ENABLED);
-                    break;
-                case HdmiTvClient.OPTION_MHL_INPUT_SWITCHING:  // Fall through
-                case HdmiTvClient.OPTION_MHL_POWER_CHARGE:
-                    if (mMhlController != null) {
-                        mMhlController.setOption(key, value);
-                    }
-                    break;
-            }
-        }
-
-        @Override
         public void setProhibitMode(final boolean enabled) {
             enforceAccessPermission();
             if (!isTvDevice()) {
@@ -1502,6 +1534,9 @@
         for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) {
             device.disableDevice(mStandbyMessageReceived, callback);
         }
+        if (isTvDevice()) {
+            unregisterSettingsObserver();
+        }
     }
 
     @ServiceThreadOnly
@@ -1527,7 +1562,7 @@
             device.onStandby(mStandbyMessageReceived);
         }
         mStandbyMessageReceived = false;
-        mCecController.setOption(HdmiTvClient.OPTION_CEC_SERVICE_CONTROL, HdmiTvClient.DISABLED);
+        mCecController.setOption(OPTION_CEC_SERVICE_CONTROL, DISABLED);
     }
 
     private void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType) {
@@ -1572,13 +1607,19 @@
     }
 
     @ServiceThreadOnly
-    private void handleHdmiControlStatusChanged(boolean enabled) {
+    void setOption(int key, int value) {
+        assertRunOnServiceThread();
+        mCecController.setOption(key, value);
+    }
+
+    @ServiceThreadOnly
+    void setControlEnabled(boolean enabled) {
         assertRunOnServiceThread();
 
-        int value = enabled ? HdmiTvClient.ENABLED : HdmiTvClient.DISABLED;
-        mCecController.setOption(HdmiTvClient.OPTION_CEC_ENABLE, value);
+        int value = toInt(enabled);
+        mCecController.setOption(OPTION_CEC_ENABLE, value);
         if (mMhlController != null) {
-            mMhlController.setOption(HdmiTvClient.OPTION_MHL_ENABLE, value);
+            mMhlController.setOption(OPTION_MHL_ENABLE, value);
         }
 
         synchronized (mLock) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 743abc8..3eb2b7e 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -16,7 +16,7 @@
 
 package com.android.server.notification;
 
-import static android.service.notification.NotificationListenerService.FLAG_DISABLE_HOST_ALERTS;
+import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS;
 import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
 import static org.xmlpull.v1.XmlPullParser.END_TAG;
 import static org.xmlpull.v1.XmlPullParser.START_TAG;
@@ -125,7 +125,7 @@
     static final int MESSAGE_RECONSIDER_RANKING = 4;
     static final int MESSAGE_RANKING_CONFIG_CHANGE = 5;
     static final int MESSAGE_SEND_RANKING_UPDATE = 6;
-    static final int MESSAGE_LISTENER_FLAGS_CHANGED = 7;
+    static final int MESSAGE_LISTENER_HINTS_CHANGED = 7;
 
     static final int LONG_DELAY = 3500; // 3.5 seconds
     static final int SHORT_DELAY = 2000; // 2 seconds
@@ -170,12 +170,12 @@
     private boolean mUseAttentionLight;
     boolean mSystemReady;
 
-    private boolean mDisableNotificationAlerts;
+    private boolean mDisableNotificationEffects;
     NotificationRecord mSoundNotification;
     NotificationRecord mVibrateNotification;
 
-    private final ArraySet<ManagedServiceInfo> mListenersDisablingAlerts = new ArraySet<>();
-    private int mListenerFlags;  // right now, all flags are global
+    private final ArraySet<ManagedServiceInfo> mListenersDisablingEffects = new ArraySet<>();
+    private int mListenerHints;  // right now, all hints are global
 
     // for enabling and disabling notification pulse behavior
     private boolean mScreenOn = true;
@@ -470,8 +470,9 @@
         @Override
         public void onSetDisabled(int status) {
             synchronized (mNotificationList) {
-                mDisableNotificationAlerts = (status & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
-                if (disableNotificationAlerts()) {
+                mDisableNotificationEffects =
+                        (status & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
+                if (disableNotificationEffects()) {
                     // cancel whatever's going on
                     long identity = Binder.clearCallingIdentity();
                     try {
@@ -804,6 +805,13 @@
             public void onConfigChanged() {
                 savePolicyFile();
             }
+
+            @Override
+            void onZenModeChanged() {
+                synchronized(mNotificationList) {
+                    updateListenerHintsLocked();
+                }
+            }
         });
         final File systemDir = new File(Environment.getDataDirectory(), "system");
         mPolicyFile = new AtomicFile(new File(systemDir, "notification_policy.xml"));
@@ -846,7 +854,7 @@
         // flag at least once and we'll go back to 0 after that.
         if (0 == Settings.Global.getInt(getContext().getContentResolver(),
                     Settings.Global.DEVICE_PROVISIONED, 0)) {
-            mDisableNotificationAlerts = true;
+            mDisableNotificationEffects = true;
         }
         mZenModeHelper.updateZenMode();
 
@@ -932,11 +940,12 @@
         }
     }
 
-    private void updateListenerFlagsLocked() {
-        final int flags = mListenersDisablingAlerts.isEmpty() ? 0 : FLAG_DISABLE_HOST_ALERTS;
-        if (flags == mListenerFlags) return;
-        mListenerFlags = flags;
-        scheduleListenerFlagsChanged(flags);
+    private void updateListenerHintsLocked() {
+        final int hints = (mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS) |
+                mZenModeHelper.getZenModeListenerHint();
+        if (hints == mListenerHints) return;
+        mListenerHints = hints;
+        scheduleListenerHintsChanged(hints);
     }
 
     private final IBinder mService = new INotificationManager.Stub() {
@@ -1284,23 +1293,29 @@
         }
 
         @Override
-        public void requestFlagsFromListener(INotificationListener token, int flags) {
-            synchronized (mNotificationList) {
-                final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
-                final boolean disableAlerts = (flags & FLAG_DISABLE_HOST_ALERTS) != 0;
-                if (disableAlerts) {
-                    mListenersDisablingAlerts.add(info);
-                } else {
-                    mListenersDisablingAlerts.remove(info);
+        public void requestHintsFromListener(INotificationListener token, int hints) {
+            final long identity = Binder.clearCallingIdentity();
+            try {
+                synchronized (mNotificationList) {
+                    final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
+                    final boolean disableEffects = (hints & HINT_HOST_DISABLE_EFFECTS) != 0;
+                    if (disableEffects) {
+                        mListenersDisablingEffects.add(info);
+                    } else {
+                        mListenersDisablingEffects.remove(info);
+                    }
+                    mZenModeHelper.requestFromListener(hints);
+                    updateListenerHintsLocked();
                 }
-                updateListenerFlagsLocked();
+            } finally {
+                Binder.restoreCallingIdentity(identity);
             }
         }
 
         @Override
-        public int getFlagsFromListener(INotificationListener token) {
+        public int getHintsFromListener(INotificationListener token) {
             synchronized (mNotificationList) {
-                return mListenerFlags;
+                return mListenerHints;
             }
         }
 
@@ -1395,8 +1410,8 @@
         return keys.toArray(new String[keys.size()]);
     }
 
-    private boolean disableNotificationAlerts() {
-        return mDisableNotificationAlerts || (mListenerFlags & FLAG_DISABLE_HOST_ALERTS) != 0;
+    private boolean disableNotificationEffects() {
+        return mDisableNotificationEffects || (mListenerHints & HINT_HOST_DISABLE_EFFECTS) != 0;
     }
 
     void dumpImpl(PrintWriter pw, DumpFilter filter) {
@@ -1447,7 +1462,7 @@
                     pw.println("  mNotificationPulseEnabled=" + mNotificationPulseEnabled);
                     pw.println("  mSoundNotification=" + mSoundNotification);
                     pw.println("  mVibrateNotification=" + mVibrateNotification);
-                    pw.println("  mDisableNotificationAlerts=" + mDisableNotificationAlerts);
+                    pw.println("  mDisableNotificationEffects=" + mDisableNotificationEffects);
                     pw.println("  mSystemReady=" + mSystemReady);
                 }
                 pw.println("  mArchive=" + mArchive.toString());
@@ -1483,11 +1498,11 @@
 
                 pw.println("\n  Notification listeners:");
                 mListeners.dump(pw, filter);
-                pw.print("    mListenerFlags: "); pw.println(mListenerFlags);
-                pw.print("    mListenersDisablingAlerts: (");
-                N = mListenersDisablingAlerts.size();
+                pw.print("    mListenerHints: "); pw.println(mListenerHints);
+                pw.print("    mListenersDisablingEffects: (");
+                N = mListenersDisablingEffects.size();
                 for (int i = 0; i < N; i++) {
-                    final ManagedServiceInfo listener = mListenersDisablingAlerts.valueAt(i);
+                    final ManagedServiceInfo listener = mListenersDisablingEffects.valueAt(i);
                     if (i > 0) pw.print(',');
                     pw.print(listener.component);
                 }
@@ -1705,7 +1720,7 @@
         }
 
         // If we're not supposed to beep, vibrate, etc. then don't.
-        if (!disableNotificationAlerts()
+        if (!disableNotificationEffects()
                 && (!(record.isUpdate
                     && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))
                 && (record.getUserId() == UserHandle.USER_ALL ||
@@ -2021,14 +2036,14 @@
         }
     }
 
-    private void scheduleListenerFlagsChanged(int state) {
-        mHandler.removeMessages(MESSAGE_LISTENER_FLAGS_CHANGED);
-        mHandler.obtainMessage(MESSAGE_LISTENER_FLAGS_CHANGED, state, 0).sendToTarget();
+    private void scheduleListenerHintsChanged(int state) {
+        mHandler.removeMessages(MESSAGE_LISTENER_HINTS_CHANGED);
+        mHandler.obtainMessage(MESSAGE_LISTENER_HINTS_CHANGED, state, 0).sendToTarget();
     }
 
-    private void handleListenerFlagsChanged(int state) {
+    private void handleListenerHintsChanged(int hints) {
         synchronized (mNotificationList) {
-            mListeners.notifyListenerFlagsChangedLocked(state);
+            mListeners.notifyListenerHintsChangedLocked(hints);
         }
     }
 
@@ -2048,8 +2063,8 @@
                 case MESSAGE_SEND_RANKING_UPDATE:
                     handleSendRankingUpdate();
                     break;
-                case MESSAGE_LISTENER_FLAGS_CHANGED:
-                    handleListenerFlagsChanged(msg.arg1);
+                case MESSAGE_LISTENER_HINTS_CHANGED:
+                    handleListenerHintsChanged(msg.arg1);
                     break;
             }
         }
@@ -2570,8 +2585,8 @@
 
         @Override
         protected void onServiceRemovedLocked(ManagedServiceInfo removed) {
-            if (mListenersDisablingAlerts.remove(removed)) {
-                updateListenerFlagsLocked();
+            if (mListenersDisablingEffects.remove(removed)) {
+                updateListenerHintsLocked();
             }
         }
 
@@ -2655,7 +2670,7 @@
             }
         }
 
-        public void notifyListenerFlagsChangedLocked(final int flags) {
+        public void notifyListenerHintsChangedLocked(final int hints) {
             for (final ManagedServiceInfo serviceInfo : mServices) {
                 if (!serviceInfo.isEnabledForCurrentProfiles()) {
                     continue;
@@ -2663,7 +2678,7 @@
                 mHandler.post(new Runnable() {
                     @Override
                     public void run() {
-                        notifyListenerFlagsChanged(serviceInfo, flags);
+                        notifyListenerHintsChanged(serviceInfo, hints);
                     }
                 });
             }
@@ -2702,12 +2717,12 @@
             }
         }
 
-        private void notifyListenerFlagsChanged(ManagedServiceInfo info, int state) {
+        private void notifyListenerHintsChanged(ManagedServiceInfo info, int hints) {
             final INotificationListener listener = (INotificationListener) info.service;
             try {
-                listener.onListenerFlagsChanged(state);
+                listener.onListenerHintsChanged(hints);
             } catch (RemoteException ex) {
-                Log.e(TAG, "unable to notify listener (listener flags): " + listener, ex);
+                Log.e(TAG, "unable to notify listener (listener hints): " + listener, ex);
             }
         }
     }
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 9f97583..9282283 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -41,6 +41,7 @@
 import android.os.UserHandle;
 import android.provider.Settings.Global;
 import android.provider.Settings.Secure;
+import android.service.notification.NotificationListenerService;
 import android.service.notification.ZenModeConfig;
 import android.telecomm.TelecommManager;
 import android.util.Slog;
@@ -125,6 +126,40 @@
         mAudioManager = audioManager;
     }
 
+    public int getZenModeListenerHint() {
+        switch(mZenMode) {
+            case Global.ZEN_MODE_OFF:
+                return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_ALL;
+            case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
+                return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_PRIORITY;
+            case Global.ZEN_MODE_NO_INTERRUPTIONS:
+                return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_NONE;
+            default:
+                return 0;
+        }
+    }
+
+    private static int zenFromListenerHint(int hints, int defValue) {
+        final int level = hints & NotificationListenerService.HOST_INTERRUPTION_LEVEL_MASK;
+        switch(level) {
+            case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_ALL:
+                return Global.ZEN_MODE_OFF;
+            case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_PRIORITY:
+                return Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+            case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_NONE:
+                return Global.ZEN_MODE_NO_INTERRUPTIONS;
+            default:
+                return defValue;
+        }
+    }
+
+    public void requestFromListener(int hints) {
+        final int newZen = zenFromListenerHint(hints, -1);
+        if (newZen != -1) {
+            setZenMode(newZen);
+        }
+    }
+
     public boolean shouldIntercept(NotificationRecord record) {
         if (mZenMode != Global.ZEN_MODE_OFF) {
             if (isSystem(record)) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 44b7f01..36dec3e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4635,12 +4635,12 @@
         // 2.) we are defering a needed dexopt
         // 3.) we are skipping an unneeded dexopt
         final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
-        for (String path : paths) {
-            for (String dexCodeInstructionSet : dexCodeInstructionSets) {
-                if (!forceDex && pkg.mDexOptPerformed.contains(dexCodeInstructionSet)) {
-                    continue;
-                }
+        for (String dexCodeInstructionSet : dexCodeInstructionSets) {
+            if (!forceDex && pkg.mDexOptPerformed.contains(dexCodeInstructionSet)) {
+                continue;
+            }
 
+            for (String path : paths) {
                 try {
                     // This will return DEXOPT_NEEDED if we either cannot find any odex file for this
                     // patckage or the one we find does not match the image checksum (i.e. it was
@@ -4661,10 +4661,9 @@
                             // just result in an error again. Also, don't bother dexopting for other
                             // paths & ISAs.
                             return DEX_OPT_FAILED;
-                        } else {
-                            performedDexOpt = true;
-                            pkg.mDexOptPerformed.add(dexCodeInstructionSet);
                         }
+
+                        performedDexOpt = true;
                     } else if (!defer && isDexOptNeeded == DexFile.PATCHOAT_NEEDED) {
                         Log.i(TAG, "Running patchoat on: " + pkg.applicationInfo.packageName);
                         final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
@@ -4676,10 +4675,9 @@
                             // just result in an error again. Also, don't bother dexopting for other
                             // paths & ISAs.
                             return DEX_OPT_FAILED;
-                        } else {
-                            performedDexOpt = true;
-                            pkg.mDexOptPerformed.add(dexCodeInstructionSet);
                         }
+
+                        performedDexOpt = true;
                     }
 
                     // We're deciding to defer a needed dexopt. Don't bother dexopting for other
@@ -4706,6 +4704,13 @@
                     return DEX_OPT_FAILED;
                 }
             }
+
+            // At this point we haven't failed dexopt and we haven't deferred dexopt. We must
+            // either have either succeeded dexopt, or have had isDexOptNeededInternal tell us
+            // it isn't required. We therefore mark that this package doesn't need dexopt unless
+            // it's forced. performedDexOpt will tell us whether we performed dex-opt or skipped
+            // it.
+            pkg.mDexOptPerformed.add(dexCodeInstructionSet);
         }
 
         // If we've gotten here, we're sure that no error occurred and that we haven't
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 23ab73c..e74de38 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1142,8 +1142,6 @@
 
     boolean showLw(boolean doAnimation, boolean requestAnim) {
         if (isHiddenFromUserLocked()) {
-            Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display "
-                    + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid);
             return false;
         }
         if (!mAppOpVisibility) {
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 3f07dd90..85dc810 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1533,8 +1533,6 @@
     // This must be called while inside a transaction.
     boolean performShowLocked() {
         if (mWin.isHiddenFromUserLocked()) {
-            Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display "
-                    + this + ", type " + mWin.mAttrs.type + ", belonging to " + mWin.mOwnerUid);
             return false;
         }
         if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW &&
diff --git a/telecomm/java/android/telecomm/Call.java b/telecomm/java/android/telecomm/Call.java
index 55cb8b1..0a54c71 100644
--- a/telecomm/java/android/telecomm/Call.java
+++ b/telecomm/java/android/telecomm/Call.java
@@ -70,7 +70,9 @@
     public static final int STATE_PRE_DIAL_WAIT = 8;
 
     /**
-     * The state of an outgoing {@code Call}, before Telecomm broadcast intent has returned.
+     * The initial state of an outgoing {@code Call}.
+     * Common transitions are to {@link #STATE_DIALING} state for a successful call or
+     * {@link #STATE_DISCONNECTED} if it failed.
      */
     public static final int STATE_CONNECTING = 9;
 
diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java
index cfa78d4..0ca4840 100644
--- a/telecomm/java/android/telecomm/CallState.java
+++ b/telecomm/java/android/telecomm/CallState.java
@@ -32,8 +32,9 @@
     NEW,
 
     /**
-     * Indicates an outgoing call has been initiated and is waiting for the broadcast intent to
-     * return and provide call details before proceeding.
+     * The initial state of an outgoing {@code Call}.
+     * Common transitions are to {@link #DIALING} state for a successful call or
+     * {@link #DISCONNECTED} if it failed.
      */
     CONNECTING,
 
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index 5e6bf87..34d35bfc 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -1073,7 +1073,7 @@
             // To be implemented by subclass.
         }
 
-        /**te
+        /**
          * Provides a response to a request to change the current call session video
          * properties.
          * This is in response to a request the InCall UI has received via
@@ -1139,8 +1139,8 @@
          * @param requestedProfile The original request which was sent to the remote device.
          * @param responseProfile The actual profile changes made by the remote device.
          */
-        public void receiveSessionModifyResponse(int status,
-                                                 VideoCallProfile requestedProfile, VideoCallProfile responseProfile) {
+        public void receiveSessionModifyResponse(
+                int status, VideoCallProfile requestedProfile, VideoCallProfile responseProfile) {
             if (mVideoCallListener != null) {
                 try {
                     mVideoCallListener.receiveSessionModifyResponse(
diff --git a/telecomm/java/com/android/internal/telecomm/IVideoCallCallback.aidl b/telecomm/java/com/android/internal/telecomm/IVideoCallCallback.aidl
index a71ab0a..1a8f68e 100644
--- a/telecomm/java/com/android/internal/telecomm/IVideoCallCallback.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IVideoCallCallback.aidl
@@ -19,14 +19,14 @@
 import android.telecomm.CallCameraCapabilities;
 import android.telecomm.VideoCallProfile;
 
- /**
-  * Internal definition of the a callback interface, used for an InCallUi to respond to video
-  * telephony changes.
-  *
-  * @see android.telecomm.InCallService.VideoCall.Listener
-  *
-  * {@hide}
-  */
+/**
+ * Internal definition of a callback interface, used for an InCallUi to respond to video telephony
+ * changes.
+ *
+ * @see android.telecomm.InCallService.VideoCall.Listener
+ *
+ * {@hide}
+ */
 oneway interface IVideoCallCallback {
     void receiveSessionModifyRequest(in VideoCallProfile videoCallProfile);
 
diff --git a/telephony/java/com/android/ims/internal/IImsCallSession.aidl b/telephony/java/com/android/ims/internal/IImsCallSession.aidl
index 5f2ff36..ba4cb01 100644
--- a/telephony/java/com/android/ims/internal/IImsCallSession.aidl
+++ b/telephony/java/com/android/ims/internal/IImsCallSession.aidl
@@ -19,6 +19,7 @@
 import com.android.ims.ImsCallProfile;
 import com.android.ims.ImsStreamMediaProfile;
 import com.android.ims.internal.IImsCallSessionListener;
+import com.android.ims.internal.IImsVideoCallProvider;
 
 /**
  * An IMS session that is associated with a SIP dialog which is established from/to
@@ -216,4 +217,11 @@
      * @param ussdMessage USSD message to send
      */
     void sendUssd(String ussdMessage);
+
+    /**
+     * Returns a binder for the video call provider implementation contained within the IMS service
+     * process. This binder is used by the VideoCallProvider subclass in Telephony which
+     * intermediates between the propriety implementation and Telecomm/InCall.
+     */
+    IImsVideoCallProvider getVideoCallProvider();
 }
diff --git a/telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl b/telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl
new file mode 100644
index 0000000..6b8ec52
--- /dev/null
+++ b/telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package com.android.ims.internal;
+
+import android.telecomm.CallCameraCapabilities;
+import android.telecomm.VideoCallProfile;
+
+/**
+ * Internal remote interface for IMS's video call provider.
+ *
+ * At least initially, this aidl mirrors telecomm's {@link VideoCallCallback}. We created a
+ * separate aidl interface for invoking callbacks in Telephony from the IMS Service to without
+ * accessing internal interfaces. See {@link IImsVideoCallProvider} for additional detail.
+ *
+ * @see android.telecomm.internal.IVideoCallCallback
+ * @see android.telecomm.VideoCallImpl
+ *
+ * {@hide}
+ */
+oneway interface IImsVideoCallCallback {
+    void receiveSessionModifyRequest(in VideoCallProfile videoCallProfile);
+
+    void receiveSessionModifyResponse(int status, in VideoCallProfile requestedProfile,
+        in VideoCallProfile responseProfile);
+
+    void handleCallSessionEvent(int event);
+
+    void changePeerDimensions(int width, int height);
+
+    void changeCallDataUsage(int dataUsage);
+
+    void changeCameraCapabilities(in CallCameraCapabilities callCameraCapabilities);
+}
diff --git a/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl b/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl
new file mode 100644
index 0000000..f8389ec
--- /dev/null
+++ b/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+package com.android.ims.internal;
+
+import android.view.Surface;
+import android.telecomm.VideoCallProfile;
+
+import com.android.ims.internal.IImsVideoCallCallback;
+
+/**
+ * Internal remote interface for IMS's video call provider.
+ *
+ * At least initially, this aidl mirrors telecomm's {@link IVideoCallProvider}. We created a
+ * separate aidl interface even though the methods and parameters are same because the
+ * {@link IVideoCallProvider} was specifically created as a binder for inter-process communication
+ * between Telecomm and Telephony.
+ *
+ * We don't want to use the same aidl in other places for communication, namely communication
+ * between Telephony and the IMS Service, even if that communication may be for similar methods.
+ * This decouples the communication among these processes. Similarly, third parties implementing a
+ * video call provider will not have the benefit of accessing the internal
+ * {@link IVideoCallProvider} aidl for interprocess communication.
+ *
+ * @see android.telecomm.internal.IVideoCallProvider
+ * @see android.telecomm.VideoCallProvider
+ * @hide
+ */
+oneway interface IImsVideoCallProvider {
+    void setCallback(IImsVideoCallCallback callback);
+
+    void setCamera(String cameraId);
+
+    void setPreviewSurface(in Surface surface);
+
+    void setDisplaySurface(in Surface surface);
+
+    void setDeviceOrientation(int rotation);
+
+    void setZoom(float value);
+
+    void sendSessionModifyRequest(in VideoCallProfile reqProfile);
+
+    void sendSessionModifyResponse(in VideoCallProfile responseProfile);
+
+    void requestCameraCapabilities();
+
+    void requestCallDataUsage();
+
+    void setPauseImage(String uri);
+}
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
index dfb8070..a209d6c 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -22,6 +22,7 @@
 import android.app.ActivityManagerNative;
 import android.app.IActivityManager;
 import android.app.IActivityManager.WaitResult;
+import android.app.UiAutomation;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -72,6 +73,18 @@
     private Bundle mResult = new Bundle();
     private Set<String> mRequiredAccounts;
 
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        getInstrumentation().getUiAutomation().setRotation(UiAutomation.ROTATION_FREEZE_0);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        getInstrumentation().getUiAutomation().setRotation(UiAutomation.ROTATION_UNFREEZE);
+        super.tearDown();
+    }
+
     public void testMeasureStartUpTime() throws RemoteException, NameNotFoundException {
         InstrumentationTestRunner instrumentation =
                 (InstrumentationTestRunner)getInstrumentation();
diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
index 051ed0e..f582a91 100644
--- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
+++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
@@ -20,6 +20,7 @@
 import android.app.ActivityManager.RunningAppProcessInfo;
 import android.app.ActivityManagerNative;
 import android.app.IActivityManager;
+import android.app.UiAutomation;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -67,6 +68,18 @@
     private Set<String> mPersistentProcesses;
     private IActivityManager mAm;
 
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        getInstrumentation().getUiAutomation().setRotation(UiAutomation.ROTATION_FREEZE_0);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        getInstrumentation().getUiAutomation().setRotation(UiAutomation.ROTATION_UNFREEZE);
+        super.tearDown();
+    }
+
     public void testMemory() {
         MemoryUsageInstrumentation instrumentation =
                 (MemoryUsageInstrumentation) getInstrumentation();
diff --git a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
index feecfde..890d68d 100644
--- a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
+++ b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
@@ -86,10 +86,10 @@
         mRouter.setRoutingCallback(new RoutingCallback(), null);
 
         mSession = new MediaSession(mContext, "OneMedia");
-        mSession.addCallback(mCallback);
-        mSession.addTransportControlsCallback(new TransportCallback());
+        mSession.setCallback(mCallback);
         mSession.setPlaybackState(mPlaybackState);
-        mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
+        mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS
+                | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
         mSession.setMediaRouter(mRouter);
         mSession.setActive(true);
     }
@@ -230,26 +230,6 @@
 
     private class SessionCb extends MediaSession.Callback {
         @Override
-        public void onMediaButtonEvent(Intent mediaRequestIntent) {
-            if (Intent.ACTION_MEDIA_BUTTON.equals(mediaRequestIntent.getAction())) {
-                KeyEvent event = (KeyEvent) mediaRequestIntent
-                        .getParcelableExtra(Intent.EXTRA_KEY_EVENT);
-                switch (event.getKeyCode()) {
-                    case KeyEvent.KEYCODE_MEDIA_PLAY:
-                        Log.d(TAG, "play button received");
-                        mRenderer.onPlay();
-                        break;
-                    case KeyEvent.KEYCODE_MEDIA_PAUSE:
-                        Log.d(TAG, "pause button received");
-                        mRenderer.onPause();
-                        break;
-                }
-            }
-        }
-    }
-
-    private class TransportCallback extends MediaSession.TransportControlsCallback {
-        @Override
         public void onPlay() {
             mRenderer.onPlay();
         }
@@ -315,7 +295,7 @@
                         updateState(PlaybackState.STATE_NONE);
                         break;
                 }
-            } 
+            }
         }
     }
 }