Merge "Fix bug 5038368 - Rules for collapsing action views."
diff --git a/api/current.txt b/api/current.txt
index 6984b07..8fc3a72 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -82,7 +82,6 @@
     field public static final java.lang.String READ_SMS = "android.permission.READ_SMS";
     field public static final java.lang.String READ_SYNC_SETTINGS = "android.permission.READ_SYNC_SETTINGS";
     field public static final java.lang.String READ_SYNC_STATS = "android.permission.READ_SYNC_STATS";
-    field public static final java.lang.String READ_WRITE_ALL_VOICEMAIL = "com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL";
     field public static final java.lang.String READ_WRITE_OWN_VOICEMAIL = "com.android.voicemail.permission.READ_WRITE_OWN_VOICEMAIL";
     field public static final java.lang.String REBOOT = "android.permission.REBOOT";
     field public static final java.lang.String RECEIVE_BOOT_COMPLETED = "android.permission.RECEIVE_BOOT_COMPLETED";
@@ -185,14 +184,14 @@
   public static final class R.attr {
     ctor public R.attr();
     field public static final int absListViewStyle = 16842858; // 0x101006a
-    field public static final int accessibilityEventTypes = 16843649; // 0x1010381
-    field public static final int accessibilityFeedbackType = 16843651; // 0x1010383
-    field public static final int accessibilityFlags = 16843653; // 0x1010385
+    field public static final int accessibilityEventTypes = 16843648; // 0x1010380
+    field public static final int accessibilityFeedbackType = 16843650; // 0x1010382
+    field public static final int accessibilityFlags = 16843652; // 0x1010384
     field public static final int accountPreferences = 16843423; // 0x101029f
     field public static final int accountType = 16843407; // 0x101028f
     field public static final int action = 16842797; // 0x101002d
     field public static final int actionBarSize = 16843499; // 0x10102eb
-    field public static final int actionBarSplitStyle = 16843675; // 0x101039b
+    field public static final int actionBarSplitStyle = 16843670; // 0x1010396
     field public static final int actionBarStyle = 16843470; // 0x10102ce
     field public static final int actionBarTabBarStyle = 16843508; // 0x10102f4
     field public static final int actionBarTabStyle = 16843507; // 0x10102f3
@@ -208,10 +207,10 @@
     field public static final int actionModeCopyDrawable = 16843538; // 0x1010312
     field public static final int actionModeCutDrawable = 16843537; // 0x1010311
     field public static final int actionModePasteDrawable = 16843539; // 0x1010313
-    field public static final int actionModeSelectAllDrawable = 16843647; // 0x101037f
-    field public static final int actionModeStyle = 16843688; // 0x10103a8
+    field public static final int actionModeSelectAllDrawable = 16843646; // 0x101037e
+    field public static final int actionModeStyle = 16843682; // 0x10103a2
     field public static final int actionOverflowButtonStyle = 16843510; // 0x10102f6
-    field public static final int actionProviderClass = 16843677; // 0x101039d
+    field public static final int actionProviderClass = 16843671; // 0x1010397
     field public static final int actionViewClass = 16843516; // 0x10102fc
     field public static final int activatedBackgroundIndicator = 16843517; // 0x10102fd
     field public static final int activityCloseEnterAnimation = 16842938; // 0x10100ba
@@ -223,7 +222,7 @@
     field public static final int alertDialogIcon = 16843605; // 0x1010355
     field public static final int alertDialogStyle = 16842845; // 0x101005d
     field public static final int alertDialogTheme = 16843529; // 0x1010309
-    field public static final int alignmentMode = 16843641; // 0x1010379
+    field public static final int alignmentMode = 16843640; // 0x1010378
     field public static final int allContactsName = 16843468; // 0x10102cc
     field public static final int allowBackup = 16843392; // 0x1010280
     field public static final int allowClearUserData = 16842757; // 0x1010005
@@ -257,8 +256,8 @@
     field public static final int background = 16842964; // 0x10100d4
     field public static final int backgroundDimAmount = 16842802; // 0x1010032
     field public static final int backgroundDimEnabled = 16843295; // 0x101021f
-    field public static final int backgroundSplit = 16843679; // 0x101039f
-    field public static final int backgroundStacked = 16843678; // 0x101039e
+    field public static final int backgroundSplit = 16843673; // 0x1010399
+    field public static final int backgroundStacked = 16843672; // 0x1010398
     field public static final int backupAgent = 16843391; // 0x101027f
     field public static final int baseline = 16843548; // 0x101031c
     field public static final int baselineAlignBottom = 16843042; // 0x1010122
@@ -267,7 +266,7 @@
     field public static final int borderlessButtonStyle = 16843563; // 0x101032b
     field public static final int bottom = 16843184; // 0x10101b0
     field public static final int bottomBright = 16842957; // 0x10100cd
-    field public static final int bottomChevronDrawable = 16843660; // 0x101038c
+    field public static final int bottomChevronDrawable = 16843659; // 0x101038b
     field public static final int bottomDark = 16842953; // 0x10100c9
     field public static final int bottomLeftRadius = 16843179; // 0x10101ab
     field public static final int bottomMedium = 16842958; // 0x10100ce
@@ -286,7 +285,7 @@
     field public static final int cacheColorHint = 16843009; // 0x1010101
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
-    field public static final int canRetrieveWindowContent = 16843654; // 0x1010386
+    field public static final int canRetrieveWindowContent = 16843653; // 0x1010385
     field public static final int candidatesTextStyleSpans = 16843312; // 0x1010230
     field public static final deprecated int capitalize = 16843113; // 0x1010169
     field public static final int centerBright = 16842956; // 0x10100cc
@@ -315,18 +314,18 @@
     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 colorActivatedHighlight = 16843684; // 0x10103a4
+    field public static final int colorActivatedHighlight = 16843678; // 0x101039e
     field public static final int colorBackground = 16842801; // 0x1010031
     field public static final int colorBackgroundCacheHint = 16843435; // 0x10102ab
-    field public static final int colorFocusedHighlight = 16843683; // 0x10103a3
+    field public static final int colorFocusedHighlight = 16843677; // 0x101039d
     field public static final int colorForeground = 16842800; // 0x1010030
     field public static final int colorForegroundInverse = 16843270; // 0x1010206
-    field public static final int colorLongPressedHighlight = 16843682; // 0x10103a2
-    field public static final int colorMultiSelectHighlight = 16843685; // 0x10103a5
-    field public static final int colorPressedHighlight = 16843681; // 0x10103a1
-    field public static final int columnCount = 16843638; // 0x1010376
+    field public static final int colorLongPressedHighlight = 16843676; // 0x101039c
+    field public static final int colorMultiSelectHighlight = 16843679; // 0x101039f
+    field public static final int colorPressedHighlight = 16843675; // 0x101039b
+    field public static final int columnCount = 16843637; // 0x1010375
     field public static final int columnDelay = 16843215; // 0x10101cf
-    field public static final int columnOrderPreserved = 16843639; // 0x1010377
+    field public static final int columnOrderPreserved = 16843638; // 0x1010376
     field public static final int columnWidth = 16843031; // 0x1010117
     field public static final int compatibleWidthLimitDp = 16843621; // 0x1010365
     field public static final int completionHint = 16843122; // 0x1010172
@@ -380,11 +379,11 @@
     field public static final int drawSelectorOnTop = 16843004; // 0x10100fc
     field public static final int drawable = 16843161; // 0x1010199
     field public static final int drawableBottom = 16843118; // 0x101016e
-    field public static final int drawableEnd = 16843687; // 0x10103a7
+    field public static final int drawableEnd = 16843681; // 0x10103a1
     field public static final int drawableLeft = 16843119; // 0x101016f
     field public static final int drawablePadding = 16843121; // 0x1010171
     field public static final int drawableRight = 16843120; // 0x1010170
-    field public static final int drawableStart = 16843686; // 0x10103a6
+    field public static final int drawableStart = 16843680; // 0x10103a0
     field public static final int drawableTop = 16843117; // 0x101016d
     field public static final int drawingCacheQuality = 16842984; // 0x10100e8
     field public static final int dropDownAnchor = 16843363; // 0x1010263
@@ -441,7 +440,7 @@
     field public static final int fastScrollTextColor = 16843609; // 0x1010359
     field public static final int fastScrollThumbDrawable = 16843574; // 0x1010336
     field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339
-    field public static final int feedbackCount = 16843666; // 0x1010392
+    field public static final int feedbackCount = 16843665; // 0x1010391
     field public static final int fillAfter = 16843197; // 0x10101bd
     field public static final int fillBefore = 16843196; // 0x10101bc
     field public static final int fillEnabled = 16843343; // 0x101024f
@@ -494,7 +493,7 @@
     field public static final int hand_hour = 16843011; // 0x1010103
     field public static final int hand_minute = 16843012; // 0x1010104
     field public static final int handle = 16843354; // 0x101025a
-    field public static final int handleDrawable = 16843656; // 0x1010388
+    field public static final int handleDrawable = 16843655; // 0x1010387
     field public static final int handleProfiling = 16842786; // 0x1010022
     field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e
     field public static final int hardwareAccelerated = 16843475; // 0x10102d3
@@ -503,12 +502,12 @@
     field public static final int headerDividersEnabled = 16843310; // 0x101022e
     field public static final int height = 16843093; // 0x1010155
     field public static final int hint = 16843088; // 0x1010150
-    field public static final int hitRadius = 16843663; // 0x101038f
+    field public static final int hitRadius = 16843662; // 0x101038e
     field public static final int homeAsUpIndicator = 16843531; // 0x101030b
     field public static final int homeLayout = 16843549; // 0x101031d
     field public static final int horizontalDivider = 16843053; // 0x101012d
     field public static final int horizontalGap = 16843327; // 0x101023f
-    field public static final int horizontalOffset = 16843668; // 0x1010394
+    field public static final int horizontalOffset = 16843667; // 0x1010393
     field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
     field public static final int horizontalSpacing = 16843028; // 0x1010114
     field public static final int host = 16842792; // 0x1010028
@@ -554,7 +553,7 @@
     field public static final int installLocation = 16843447; // 0x10102b7
     field public static final int interpolator = 16843073; // 0x1010141
     field public static final int isAlwaysSyncable = 16843571; // 0x1010333
-    field public static final int isAuxiliary = 16843648; // 0x1010380
+    field public static final int isAuxiliary = 16843647; // 0x101037f
     field public static final int isDefault = 16843297; // 0x1010221
     field public static final int isIndicator = 16843079; // 0x1010147
     field public static final int isModifier = 16843334; // 0x1010246
@@ -591,7 +590,6 @@
     field public static final int layerType = 16843604; // 0x1010354
     field public static final int layout = 16842994; // 0x10100f2
     field public static final int layoutAnimation = 16842988; // 0x10100ec
-    field public static final int layoutDirection = 16843634; // 0x1010372
     field public static final int layout_above = 16843140; // 0x1010184
     field public static final int layout_alignBaseline = 16843142; // 0x1010186
     field public static final int layout_alignBottom = 16843146; // 0x101018a
@@ -608,20 +606,18 @@
     field public static final int layout_centerInParent = 16843151; // 0x101018f
     field public static final int layout_centerVertical = 16843153; // 0x1010191
     field public static final int layout_column = 16843084; // 0x101014c
-    field public static final int layout_columnFlexibility = 16843646; // 0x101037e
-    field public static final int layout_columnSpan = 16843645; // 0x101037d
+    field public static final int layout_columnFlexibility = 16843645; // 0x101037d
+    field public static final int layout_columnSpan = 16843644; // 0x101037c
     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
     field public static final int layout_marginBottom = 16843002; // 0x10100fa
-    field public static final int layout_marginEnd = 16843674; // 0x101039a
     field public static final int layout_marginLeft = 16842999; // 0x10100f7
     field public static final int layout_marginRight = 16843001; // 0x10100f9
-    field public static final int layout_marginStart = 16843673; // 0x1010399
     field public static final int layout_marginTop = 16843000; // 0x10100f8
-    field public static final int layout_row = 16843642; // 0x101037a
-    field public static final int layout_rowFlexibility = 16843644; // 0x101037c
-    field public static final int layout_rowSpan = 16843643; // 0x101037b
+    field public static final int layout_row = 16843641; // 0x1010379
+    field public static final int layout_rowFlexibility = 16843643; // 0x101037b
+    field public static final int layout_rowSpan = 16843642; // 0x101037a
     field public static final int layout_scale = 16843155; // 0x1010193
     field public static final int layout_span = 16843085; // 0x101014d
     field public static final int layout_toLeftOf = 16843138; // 0x1010182
@@ -631,7 +627,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 leftChevronDrawable = 16843657; // 0x1010389
+    field public static final int leftChevronDrawable = 16843656; // 0x1010388
     field public static final int lineSpacingExtra = 16843287; // 0x1010217
     field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
     field public static final int lines = 16843092; // 0x1010154
@@ -643,8 +639,8 @@
     field public static final int listDividerAlertDialog = 16843525; // 0x1010305
     field public static final int listPopupWindowStyle = 16843519; // 0x10102ff
     field public static final int listPreferredItemHeight = 16842829; // 0x101004d
-    field public static final int listPreferredItemHeightLarge = 16843669; // 0x1010395
-    field public static final int listPreferredItemHeightSmall = 16843670; // 0x1010396
+    field public static final int listPreferredItemHeightLarge = 16843668; // 0x1010394
+    field public static final int listPreferredItemHeightSmall = 16843669; // 0x1010395
     field public static final int listSelector = 16843003; // 0x10100fb
     field public static final int listSeparatorTextViewStyle = 16843272; // 0x1010208
     field public static final int listViewStyle = 16842868; // 0x1010074
@@ -675,8 +671,8 @@
     field public static final int minHeight = 16843072; // 0x1010140
     field public static final int minLevel = 16843185; // 0x10101b1
     field public static final int minLines = 16843094; // 0x1010156
-    field public static final int minResizeHeight = 16843690; // 0x10103aa
-    field public static final int minResizeWidth = 16843689; // 0x10103a9
+    field public static final int minResizeHeight = 16843684; // 0x10103a4
+    field public static final int minResizeWidth = 16843683; // 0x10103a3
     field public static final int minSdkVersion = 16843276; // 0x101020c
     field public static final int minWidth = 16843071; // 0x101013f
     field public static final int mode = 16843134; // 0x101017e
@@ -692,7 +688,7 @@
     field public static final int nextFocusUp = 16842979; // 0x10100e3
     field public static final int noHistory = 16843309; // 0x101022d
     field public static final int normalScreens = 16843397; // 0x1010285
-    field public static final int notificationTimeout = 16843652; // 0x1010384
+    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 deprecated int numeric = 16843109; // 0x1010165
@@ -706,17 +702,15 @@
     field public static final int orderingFromXml = 16843239; // 0x10101e7
     field public static final int orientation = 16842948; // 0x10100c4
     field public static final int outAnimation = 16843128; // 0x1010178
-    field public static final int outerRadius = 16843662; // 0x101038e
+    field public static final int outerRadius = 16843661; // 0x101038d
     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 packageNames = 16843650; // 0x1010382
+    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 = 16843672; // 0x1010398
     field public static final int paddingLeft = 16842966; // 0x10100d6
     field public static final int paddingRight = 16842968; // 0x10100d8
-    field public static final int paddingStart = 16843671; // 0x1010397
     field public static final int paddingTop = 16842967; // 0x10100d7
     field public static final int panelBackground = 16842846; // 0x101005e
     field public static final int panelColorBackground = 16842849; // 0x1010061
@@ -797,17 +791,17 @@
     field public static final int restoreAnyVersion = 16843450; // 0x10102ba
     field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d
     field public static final int right = 16843183; // 0x10101af
-    field public static final int rightChevronDrawable = 16843658; // 0x101038a
+    field public static final int rightChevronDrawable = 16843657; // 0x1010389
     field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
     field public static final int ringtoneType = 16843257; // 0x10101f9
     field public static final int rotation = 16843558; // 0x1010326
     field public static final int rotationX = 16843559; // 0x1010327
     field public static final int rotationY = 16843560; // 0x1010328
-    field public static final int rowCount = 16843636; // 0x1010374
+    field public static final int rowCount = 16843635; // 0x1010373
     field public static final int rowDelay = 16843216; // 0x10101d0
     field public static final int rowEdgeFlags = 16843329; // 0x1010241
     field public static final int rowHeight = 16843058; // 0x1010132
-    field public static final int rowOrderPreserved = 16843637; // 0x1010375
+    field public static final int rowOrderPreserved = 16843636; // 0x1010374
     field public static final int saveEnabled = 16842983; // 0x10100e7
     field public static final int scaleGravity = 16843262; // 0x10101fe
     field public static final int scaleHeight = 16843261; // 0x10101fd
@@ -873,7 +867,7 @@
     field public static final int smallIcon = 16843422; // 0x101029e
     field public static final int smallScreens = 16843396; // 0x1010284
     field public static final int smoothScrollbar = 16843313; // 0x1010231
-    field public static final int snapMargin = 16843665; // 0x1010391
+    field public static final int snapMargin = 16843664; // 0x1010390
     field public static final int soundEffectsEnabled = 16843285; // 0x1010215
     field public static final int spacing = 16843027; // 0x1010113
     field public static final int spinnerDropDownItemStyle = 16842887; // 0x1010087
@@ -921,7 +915,7 @@
     field public static final int subtitleTextStyle = 16843513; // 0x10102f9
     field public static final int suggestActionMsg = 16843228; // 0x10101dc
     field public static final int suggestActionMsgColumn = 16843229; // 0x10101dd
-    field public static final int suggestionsEnabled = 16843635; // 0x1010373
+    field public static final int suggestionsEnabled = 16843634; // 0x1010372
     field public static final int summary = 16843241; // 0x10101e9
     field public static final int summaryColumn = 16843426; // 0x10102a2
     field public static final int summaryOff = 16843248; // 0x10101f0
@@ -938,7 +932,7 @@
     field public static final int tag = 16842961; // 0x10100d1
     field public static final int targetActivity = 16843266; // 0x1010202
     field public static final int targetClass = 16842799; // 0x101002f
-    field public static final int targetDrawables = 16843655; // 0x1010387
+    field public static final int targetDrawables = 16843654; // 0x1010386
     field public static final int targetPackage = 16842785; // 0x1010021
     field public static final int targetSdkVersion = 16843376; // 0x1010270
     field public static final int taskAffinity = 16842770; // 0x1010012
@@ -953,7 +947,7 @@
     field public static final int tension = 16843370; // 0x101026a
     field public static final int testOnly = 16843378; // 0x1010272
     field public static final int text = 16843087; // 0x101014f
-    field public static final int textAllCaps = 16843680; // 0x10103a0
+    field public static final int textAllCaps = 16843674; // 0x101039a
     field public static final int textAppearance = 16842804; // 0x1010034
     field public static final int textAppearanceButton = 16843271; // 0x1010207
     field public static final int textAppearanceInverse = 16842805; // 0x1010035
@@ -990,7 +984,6 @@
     field public static final int textColorTertiary = 16843282; // 0x1010212
     field public static final int textColorTertiaryInverse = 16843283; // 0x1010213
     field public static final int textCursorDrawable = 16843618; // 0x1010362
-    field public static final int textDirection = 16843676; // 0x101039c
     field public static final int textEditNoPasteWindowLayout = 16843541; // 0x1010315
     field public static final int textEditPasteWindowLayout = 16843540; // 0x1010314
     field public static final int textEditSideNoPasteWindowLayout = 16843615; // 0x101035f
@@ -1030,7 +1023,7 @@
     field public static final int toYScale = 16843205; // 0x10101c5
     field public static final int top = 16843182; // 0x10101ae
     field public static final int topBright = 16842955; // 0x10100cb
-    field public static final int topChevronDrawable = 16843659; // 0x101038b
+    field public static final int topChevronDrawable = 16843658; // 0x101038a
     field public static final int topDark = 16842951; // 0x10100c7
     field public static final int topLeftRadius = 16843177; // 0x10101a9
     field public static final int topOffset = 16843352; // 0x1010258
@@ -1046,7 +1039,7 @@
     field public static final int unfocusedMonthDateColor = 16843588; // 0x1010344
     field public static final int unselectedAlpha = 16843278; // 0x101020e
     field public static final int updatePeriodMillis = 16843344; // 0x1010250
-    field public static final int useDefaultMargins = 16843640; // 0x1010378
+    field public static final int useDefaultMargins = 16843639; // 0x1010377
     field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
     field public static final int useLevel = 16843167; // 0x101019f
     field public static final int userVisible = 16843409; // 0x1010291
@@ -1060,10 +1053,10 @@
     field public static final int verticalCorrection = 16843322; // 0x101023a
     field public static final int verticalDivider = 16843054; // 0x101012e
     field public static final int verticalGap = 16843328; // 0x1010240
-    field public static final int verticalOffset = 16843667; // 0x1010393
+    field public static final int verticalOffset = 16843666; // 0x1010392
     field public static final int verticalScrollbarPosition = 16843572; // 0x1010334
     field public static final int verticalSpacing = 16843029; // 0x1010115
-    field public static final int vibrationDuration = 16843664; // 0x1010390
+    field public static final int vibrationDuration = 16843663; // 0x101038f
     field public static final int visibility = 16842972; // 0x10100dc
     field public static final int visible = 16843156; // 0x1010194
     field public static final int vmSafeMode = 16843448; // 0x10102b8
@@ -1080,7 +1073,7 @@
     field public static final int wallpaperIntraOpenExitAnimation = 16843416; // 0x1010298
     field public static final int wallpaperOpenEnterAnimation = 16843411; // 0x1010293
     field public static final int wallpaperOpenExitAnimation = 16843412; // 0x1010294
-    field public static final int waveDrawable = 16843661; // 0x101038d
+    field public static final int waveDrawable = 16843660; // 0x101038c
     field public static final int webTextViewStyle = 16843449; // 0x10102b9
     field public static final int webViewStyle = 16842885; // 0x1010085
     field public static final int weekDayTextAppearance = 16843592; // 0x1010348
@@ -16238,12 +16231,14 @@
   }
 
   public static final class ContactsContract.StreamItemPhotos implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemPhotosColumns {
+    field public static final java.lang.String PHOTO = "photo";
   }
 
   protected static abstract interface ContactsContract.StreamItemPhotosColumns {
     field public static final java.lang.String ACTION = "action";
     field public static final java.lang.String ACTION_URI = "action_uri";
-    field public static final java.lang.String PICTURE = "picture";
+    field public static final java.lang.String PHOTO_FILE_ID = "photo_file_id";
+    field public static final java.lang.String PHOTO_URI = "photo_uri";
     field public static final java.lang.String SORT_INDEX = "sort_index";
     field public static final java.lang.String STREAM_ITEM_ID = "stream_item_id";
   }
@@ -16253,7 +16248,6 @@
     field public static final android.net.Uri CONTENT_PHOTO_URI;
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String MAX_ITEMS = "max_items";
-    field public static final java.lang.String PHOTO_MAX_BYTES = "photo_max_bytes";
   }
 
   public static final class ContactsContract.StreamItems.StreamItemPhotos implements android.provider.BaseColumns android.provider.ContactsContract.StreamItemPhotosColumns {
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index 2952e6b..f99b420 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -536,9 +536,11 @@
          */
         public final Activity waitForActivityWithTimeout(long timeOut) {
             synchronized (this) {
-                try {
-                    wait(timeOut);
-                } catch (InterruptedException e) {
+                if (mLastActivity == null) {
+                    try {
+                        wait(timeOut);
+                    } catch (InterruptedException e) {
+                    }
                 }
                 if (mLastActivity == null) {
                     return null;
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 76f198c..c299891 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -1747,9 +1747,9 @@
          *     Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
          *     try {
          *         AssetFileDescriptor fd =
-         *             getContentResolver().openAssetFile(displayPhotoUri, "r");
+         *             getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
          *         return fd.createInputStream();
-         *     } catch (FileNotFoundException e) {
+         *     } catch (IOException e) {
          *         return null;
          *     }
          * }
@@ -2586,7 +2586,7 @@
          * display photo.  To access this directory append
          * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
          * The resulting URI represents an image file, and should be interacted with
-         * using ContentProvider.openAssetFile.
+         * using ContentResolver.openAssetFileDescriptor.
          * <p>
          * <p>
          * Note that this sub-directory also supports opening the photo as an asset file
@@ -2605,7 +2605,7 @@
          *             RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
          *     try {
          *         AssetFileDescriptor fd =
-         *             getContentResolver().openAssetFile(rawContactPhotoUri, "rw");
+         *             getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
          *         OutputStream os = fd.createOutputStream();
          *         os.write(photo);
          *         os.close();
@@ -2804,7 +2804,7 @@
 
         /**
          * The package containing resources for this status: label and icon.
-         * <p>Type: NUMBER</p>
+         * <p>Type: TEXT</p>
          */
         public static final String STATUS_RES_PACKAGE = "status_res_package";
 
@@ -2872,7 +2872,7 @@
      * ContentValues values = new ContentValues();
      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
      * values.put(StreamItems.TIMESTAMP, timestamp);
-     * values.put(StreamItems.COMMENT, "3 people reshared this");
+     * values.put(StreamItems.COMMENTS, "3 people reshared this");
      * values.put(StreamItems.ACTION, action);
      * values.put(StreamItems.ACTION_URI, actionUri);
      * Uri streamItemUri = getContentResolver().insert(
@@ -2887,7 +2887,7 @@
      * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
      * values.put(StreamItems.TIMESTAMP, timestamp);
-     * values.put(StreamItems.COMMENT, "3 people reshared this");
+     * values.put(StreamItems.COMMENTS, "3 people reshared this");
      * values.put(StreamItems.ACTION, action);
      * values.put(StreamItems.ACTION_URI, actionUri);
      * Uri streamItemUri = getContentResolver().insert(StreamItems.CONTENT_URI, values);
@@ -2906,7 +2906,7 @@
      * <pre>
      * values.clear();
      * values.put(StreamItemPhotos.SORT_INDEX, 1);
-     * values.put(StreamItemPhotos.PICTURE, photoData);
+     * values.put(StreamItemPhotos.PHOTO, photoData);
      * values.put(StreamItemPhotos.ACTION, action);
      * values.put(StreamItemPhotos.ACTION_URI, actionUri);
      * getContentResolver().insert(Uri.withAppendedPath(
@@ -2920,7 +2920,7 @@
      * values.clear();
      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
      * values.put(StreamItemPhotos.SORT_INDEX, 1);
-     * values.put(StreamItemPhotos.PICTURE, photoData);
+     * values.put(StreamItemPhotos.PHOTO, photoData);
      * values.put(StreamItemPhotos.ACTION, action);
      * values.put(StreamItemPhotos.ACTION_URI, actionUri);
      * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
@@ -3008,8 +3008,7 @@
 
         /**
          * This URI allows the caller to query for the maximum number of stream items
-         * that will be stored under any single raw contact, as well as the maximum
-         * photo size (in bytes) accepted in stream item photos.
+         * that will be stored under any single raw contact.
          */
         public static final Uri CONTENT_LIMIT_URI =
                 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
@@ -3022,13 +3021,6 @@
         public static final String MAX_ITEMS = "max_items";
 
         /**
-         * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
-         * contain this column, with the value indicating the byte limit for
-         * individual photos.
-         */
-        public static final String PHOTO_MAX_BYTES = "photo_max_bytes";
-
-        /**
          * <p>
          * A sub-directory of a single stream item entry that contains all of its
          * photo rows. To access this
@@ -3067,7 +3059,7 @@
          * The package name to use when creating {@link Resources} objects for
          * this stream item. This value is only designed for use when building
          * user interfaces, and should not be used to infer the owner.
-         * <P>Type: NUMBER</P>
+         * <P>Type: TEXT</P>
          */
         public static final String RES_PACKAGE = "res_package";
 
@@ -3161,7 +3153,7 @@
      * <pre>
      * ContentValues values = new ContentValues();
      * values.put(StreamItemPhotos.SORT_INDEX, 1);
-     * values.put(StreamItemPhotos.PICTURE, photoData);
+     * values.put(StreamItemPhotos.PHOTO, photoData);
      * values.put(StreamItemPhotos.ACTION, action);
      * values.put(StreamItemPhotos.ACTION_URI, actionUri);
      * Uri photoUri = getContentResolver().insert(Uri.withAppendedPath(
@@ -3176,7 +3168,7 @@
      * ContentValues values = new ContentValues();
      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
      * values.put(StreamItemPhotos.SORT_INDEX, 1);
-     * values.put(StreamItemPhotos.PICTURE, photoData);
+     * values.put(StreamItemPhotos.PHOTO, photoData);
      * values.put(StreamItemPhotos.ACTION, action);
      * values.put(StreamItemPhotos.ACTION_URI, actionUri);
      * Uri photoUri = getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
@@ -3198,7 +3190,7 @@
      * <dd>
      * <pre>
      * ContentValues values = new ContentValues();
-     * values.put(StreamItemPhotos.PICTURE, newPhotoData);
+     * values.put(StreamItemPhotos.PHOTO, newPhotoData);
      * getContentResolver().update(
      *     ContentUris.withAppendedId(
      *         Uri.withAppendedPath(
@@ -3212,7 +3204,7 @@
      * <pre>
      * ContentValues values = new ContentValues();
      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
-     * values.put(StreamItemPhotos.PICTURE, newPhotoData);
+     * values.put(StreamItemPhotos.PHOTO, newPhotoData);
      * getContentResolver().update(StreamItems.CONTENT_PHOTO_URI, values);
      * </pre>
      * </dd>
@@ -3271,6 +3263,21 @@
      *     null, null, null, StreamItemPhotos.SORT_INDEX);
      * </pre>
      * </dl>
+     * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
+     * {@link StreamItemPhotos#PHOTO_URI}.  The {@link StreamItemPhotos#PHOTO_FILE_ID}
+     * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
+     * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
+     * an asset file, as follows:
+     * <pre>
+     * public InputStream openDisplayPhoto(String photoUri) {
+     *     try {
+     *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
+     *         return fd.createInputStream();
+     *     } catch (IOException e) {
+     *         return null;
+     *     }
+     * }
+     * <pre>
      * </dd>
      * </dl>
      */
@@ -3280,6 +3287,20 @@
          */
         private StreamItemPhotos() {
         }
+
+        /**
+         * <p>
+         * The binary representation of the photo.  Any size photo can be inserted;
+         * the provider will resize it appropriately for storage and display.
+         * </p>
+         * <p>
+         * This is only intended for use when inserting or updating a stream item photo.
+         * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
+         * as an asset file.
+         * </p>
+         * <P>Type: BLOB</P>
+         */
+        public static final String PHOTO = "photo";
     }
 
     /**
@@ -3302,13 +3323,18 @@
         public static final String SORT_INDEX = "sort_index";
 
         /**
-         * The binary representation of the picture.  Pictures larger than
-         * {@link ContactsContract.StreamItems#PHOTO_MAX_BYTES} bytes in size (as
-         * queryable from {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI})
-         * will be rejected.
-         * <P>Type: BLOB</P>
+         * Photo file ID for the photo.
+         * See {@link ContactsContract.DisplayPhoto}.
+         * <P>Type: NUMBER</P>
          */
-        public static final String PICTURE = "picture";
+        public static final String PHOTO_FILE_ID = "photo_file_id";
+
+        /**
+         * URI for retrieving the photo content, automatically populated.  Callers
+         * may retrieve the photo content by opening this URI as an asset file.
+         * <P>Type: TEXT</P>
+         */
+        public static final String PHOTO_URI = "photo_uri";
 
         /**
          * The activity action to execute when the photo is tapped.
@@ -7273,9 +7299,10 @@
      * public InputStream openDisplayPhoto(long photoFileId) {
      *     Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
      *     try {
-     *         AssetFileDescriptor fd = getContentResolver().openAssetFile(displayPhotoUri, "r");
+     *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
+     *             displayPhotoUri, "r");
      *         return fd.createInputStream();
-     *     } catch (FileNotFoundException e) {
+     *     } catch (IOException e) {
      *         return null;
      *     }
      * }
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index f3bcedb..f799af3 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -283,13 +283,6 @@
          */
         public static final String IS_DRM = "is_drm";
 
-        /**
-         * Used by the media scanner to suppress files from being processed as media files.
-         *
-         * <P>Type: INTEGER (boolean)</P>
-         * @hide
-         */
-        public static final String NO_MEDIA = "no_media";
      }
 
     /**
diff --git a/core/java/android/util/JsonReader.java b/core/java/android/util/JsonReader.java
index 09ce8e4..f139372 100644
--- a/core/java/android/util/JsonReader.java
+++ b/core/java/android/util/JsonReader.java
@@ -738,6 +738,14 @@
         int total;
         while ((total = in.read(buffer, limit, buffer.length - limit)) != -1) {
             limit += total;
+
+            // if this is the first read, consume an optional byte order mark (BOM) if it exists
+            if (bufferStartLine == 1 && bufferStartColumn == 1
+                    && limit > 0 && buffer[0] == '\ufeff') {
+                pos++;
+                bufferStartColumn--;
+            }
+
             if (limit >= minimum) {
                 return true;
             }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index ff5fa7f..0108ecf 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -607,8 +607,6 @@
  * @attr ref android.R.styleable#View_paddingLeft
  * @attr ref android.R.styleable#View_paddingRight
  * @attr ref android.R.styleable#View_paddingTop
- * @attr ref android.R.styleable#View_paddingStart
- * @attr ref android.R.styleable#View_paddingEnd
  * @attr ref android.R.styleable#View_saveEnabled
  * @attr ref android.R.styleable#View_rotation
  * @attr ref android.R.styleable#View_rotationX
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 290f049..103a326 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -300,15 +300,6 @@
         android:label="@string/permlab_readWriteOwnVoicemail"
         android:description="@string/permdesc_readWriteOwnVoicemail" />
 
-   <!-- Allows an application to read/write all voicemails. In order to be able
-        access all voicemails, this permission is needed in *addition* to
-        READ_WRITE_OWN_VOICEMAIL. -->
-    <permission android:name="com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL"
-        android:permissionGroup="android.permission-group.PERSONAL_INFO"
-        android:protectionLevel="signature"
-        android:label="@string/permlab_readWriteAllVoicemail"
-        android:description="@string/permdesc_readWriteAllVoicemail" />
-
     <!-- ======================================= -->
     <!-- Permissions for accessing location info -->
     <!-- ======================================= -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index ba2a036..75f0c4e 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1719,8 +1719,6 @@
   <public type="attr" name="textEditSuggestionsTopWindowLayout" />
   <public type="attr" name="textEditSuggestionItemLayout" />
 
-  <public type="attr" name="layoutDirection" />
-
   <public type="attr" name="suggestionsEnabled" />
 
   <public type="attr" name="rowCount" />
@@ -1765,15 +1763,8 @@
   <public type="attr" name="listPreferredItemHeightLarge" />
   <public type="attr" name="listPreferredItemHeightSmall" />
 
-  <public type="attr" name="paddingStart"/>
-  <public type="attr" name="paddingEnd"/>
-  <public type="attr" name="layout_marginStart"/>
-  <public type="attr" name="layout_marginEnd"/>
-
   <public type="attr" name="actionBarSplitStyle" />
 
-  <public type="attr" name="textDirection"/>
-
   <public type="attr" name="actionProviderClass" />
 
   <public type="attr" name="backgroundStacked" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 64f7316..419734a 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2160,14 +2160,6 @@
       voicemails that its associated service can access.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether
-        they want to allow the application to do this.  [CHAR LIMIT=NONE] -->
-    <string name="permlab_readWriteAllVoicemail">Access all voicemails</string>
-    <!-- Description of an application permission, listed so the user can choose whether
-        they want to allow the application to do this. [CHAR LIMIT=NONE] -->
-    <string name="permdesc_readWriteAllVoicemail">Allows the application to store and retrieve all
-      voicemails that this device can access.</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_writeGeolocationPermissions">Modify Browser geolocation permissions</string>
     <!-- Description of an application permission, listed so the user can choose whether
diff --git a/core/tests/coretests/src/android/util/JsonReaderTest.java b/core/tests/coretests/src/android/util/JsonReaderTest.java
index 0b50af3..42b7640 100644
--- a/core/tests/coretests/src/android/util/JsonReaderTest.java
+++ b/core/tests/coretests/src/android/util/JsonReaderTest.java
@@ -857,11 +857,32 @@
         }
     }
 
+    public void testBomIgnoredAsFirstCharacterOfDocument() throws IOException {
+        JsonReader reader = new JsonReader(new StringReader("\ufeff[]"));
+        reader.beginArray();
+        reader.endArray();
+    }
+
+    public void testBomForbiddenAsOtherCharacterInDocument() throws IOException {
+        JsonReader reader = new JsonReader(new StringReader("[\ufeff]"));
+        reader.beginArray();
+        try {
+            reader.endArray();
+            fail();
+        } catch (IOException expected) {
+        }
+    }
+
     public void testFailWithPosition() throws IOException {
         testFailWithPosition("Expected literal value at line 6 column 3",
                 "[\n\n\n\n\n0,}]");
     }
 
+    public void testFailWithPositionIsOffsetByBom() throws IOException {
+        testFailWithPosition("Expected literal value at line 1 column 4",
+                "\ufeff[0,}]");
+    }
+
     public void testFailWithPositionGreaterThanBufferSize() throws IOException {
         String spaces = repeat(' ', 8192);
         testFailWithPosition("Expected literal value at line 6 column 3",
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
index 29dec63..0adba06 100755
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -325,7 +325,7 @@
         }
         catch (UnsupportedEncodingException e)
         {
-            Log.e(TAG, e.getMessage());
+            throw new AssertionError();
         }
         return decoded;
     }
@@ -338,7 +338,7 @@
         }
         catch (UnsupportedEncodingException e)
         {
-            Log.e(TAG, e.getMessage());
+            throw new AssertionError();
         }
         return decoded;
     }
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 2e9b64c..682560a 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -332,10 +332,10 @@
                 SOUND_EFFECT_DEFAULT_VOLUME_DB);
 
         mVolumePanel = new VolumePanel(context, this);
-        mSettingsObserver = new SettingsObserver();
         mForcedUseForComm = AudioSystem.FORCE_NONE;
         createAudioSystemThread();
         readPersistedSettings();
+        mSettingsObserver = new SettingsObserver();
         createStreamStates();
         // Call setMode() to initialize mSetModeDeathHandlers
         mMode = AudioSystem.MODE_INVALID;
@@ -433,15 +433,20 @@
 
         mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0);
 
+        // make sure settings for ringer mode are consistent with device type: non voice capable
+        // devices (tablets) include media stream in silent mode whereas phones don't.
         mRingerModeAffectedStreams = Settings.System.getInt(cr,
                 Settings.System.MODE_RINGER_STREAMS_AFFECTED,
                 ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)|
-                 (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)|
-                 (1 << AudioSystem.STREAM_MUSIC)));
-
-        if (!mVoiceCapable) {
+                 (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)));
+        if (mVoiceCapable) {
+            mRingerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC);
+        } else {
             mRingerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC);
         }
+        Settings.System.putInt(cr,
+                Settings.System.MODE_RINGER_STREAMS_AFFECTED, mRingerModeAffectedStreams);
+
         mMuteAffectedStreams = System.getInt(cr,
                 System.MUTE_STREAMS_AFFECTED,
                 ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM)));
@@ -2172,12 +2177,14 @@
             super.onChange(selfChange);
             synchronized (mSettingsLock) {
                 int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver,
-                        Settings.System.MODE_RINGER_STREAMS_AFFECTED,
-                        0);
-                if (!mVoiceCapable) {
+                       Settings.System.MODE_RINGER_STREAMS_AFFECTED,
+                       ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)|
+                       (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)));
+                if (mVoiceCapable) {
+                    ringerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC);
+                } else {
                     ringerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC);
                 }
-
                 if (ringerModeAffectedStreams != mRingerModeAffectedStreams) {
                     /*
                      * Ensure all stream types that should be affected by ringer mode
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 8c8569a..a8ac510 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -372,8 +372,14 @@
 
     private class FileInserter {
 
-        ContentValues[] mValues = new ContentValues[1000];
-        int mIndex = 0;
+        private final Uri mUri;
+        private final ContentValues[] mValues;
+        private int mIndex;
+
+        public FileInserter(Uri uri, int count) {
+            mUri = uri;
+            mValues = new ContentValues[count];
+        }
 
         public Uri insert(ContentValues values) {
             if (mIndex == mValues.length) {
@@ -389,13 +395,17 @@
                 mValues[mIndex++] = null;
             }
             try {
-                mMediaProvider.bulkInsert(mFilesUri, mValues);
+                mMediaProvider.bulkInsert(mUri, mValues);
             } catch (RemoteException e) {
                 Log.e(TAG, "RemoteException in FileInserter.flush()", e);
             }
             mIndex = 0;
         }
     }
+
+    private FileInserter mAudioInserter;
+    private FileInserter mVideoInserter;
+    private FileInserter mImageInserter;
     private FileInserter mFileInserter;
 
     // hashes file path to FileCacheEntry.
@@ -707,9 +717,7 @@
             map.put(MediaStore.MediaColumns.MIME_TYPE, mMimeType);
             map.put(MediaStore.MediaColumns.IS_DRM, mIsDrm);
 
-            if (mNoMedia) {
-                map.put(MediaStore.MediaColumns.NO_MEDIA, true);
-            } else {
+            if (!mNoMedia) {
                 if (MediaFile.isVideoFileType(mFileType)) {
                     map.put(Video.Media.ARTIST, (mArtist != null && mArtist.length() > 0
                             ? mArtist : MediaStore.UNKNOWN_STRING));
@@ -837,23 +845,35 @@
                 }
             }
 
-            // For inserts we always use the file URI so we can insert in bulk.
-            // For updates we compute the URI based on the media type.
             Uri tableUri = mFilesUri;
+            FileInserter inserter = mFileInserter;
+            if (!mNoMedia) {
+                if (MediaFile.isVideoFileType(mFileType)) {
+                    tableUri = mVideoUri;
+                    inserter = mVideoInserter;
+                } else if (MediaFile.isImageFileType(mFileType)) {
+                    tableUri = mImagesUri;
+                    inserter = mImageInserter;
+                } else if (MediaFile.isAudioFileType(mFileType)) {
+                    tableUri = mAudioUri;
+                    inserter = mAudioInserter;
+                }
+            }
             Uri result = null;
             if (rowId == 0) {
                 if (mMtpObjectHandle != 0) {
                     values.put(MediaStore.MediaColumns.MEDIA_SCANNER_NEW_OBJECT_ID, mMtpObjectHandle);
                 }
-                int format = entry.mFormat;
-                if (format == 0) {
-                    format = MediaFile.getFormatCode(entry.mPath, mMimeType);
+                if (tableUri == mFilesUri) {
+                    int format = entry.mFormat;
+                    if (format == 0) {
+                        format = MediaFile.getFormatCode(entry.mPath, mMimeType);
+                    }
+                    values.put(Files.FileColumns.FORMAT, format);
                 }
-                values.put(Files.FileColumns.FORMAT, format);
-
                 // new file, insert it
-                if (mFileInserter != null) {
-                    result = mFileInserter.insert(values);
+                if (inserter != null) {
+                    result = inserter.insert(values);
                 } else {
                     result = mMediaProvider.insert(tableUri, values);
                 }
@@ -863,16 +883,6 @@
                     entry.mRowId = rowId;
                 }
             } else {
-                if (!mNoMedia) {
-                    if (MediaFile.isVideoFileType(mFileType)) {
-                        tableUri = mVideoUri;
-                    } else if (MediaFile.isImageFileType(mFileType)) {
-                        tableUri = mImagesUri;
-                    } else if (MediaFile.isAudioFileType(mFileType)) {
-                        tableUri = mAudioUri;
-                    }
-                }
-
                 // updated file
                 result = ContentUris.withAppendedId(tableUri, rowId);
                 // path should never change, and we want to avoid replacing mixed cased paths
@@ -1200,12 +1210,25 @@
             initialize(volumeName);
             prescan(null, true);
             long prescan = System.currentTimeMillis();
-            mFileInserter = new FileInserter();
+
+            // create FileInserters for bulk inserts
+            mAudioInserter = new FileInserter(mAudioUri, 500);
+            mVideoInserter = new FileInserter(mVideoUri, 500);
+            mImageInserter = new FileInserter(mImagesUri, 500);
+            mFileInserter = new FileInserter(mFilesUri, 500);
 
             for (int i = 0; i < directories.length; i++) {
                 processDirectory(directories[i], mClient);
             }
+
+            // flush remaining inserts
+            mAudioInserter.flush();
+            mVideoInserter.flush();
+            mImageInserter.flush();
             mFileInserter.flush();
+            mAudioInserter = null;
+            mVideoInserter = null;
+            mImageInserter = null;
             mFileInserter = null;
 
             long scan = System.currentTimeMillis();
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 178039c..ed6e3c7 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -84,6 +84,8 @@
     if (p != 0) {
         p->disconnect();
     }
+
+    disconnectNativeWindow();
 }
 
 // always call with lock held
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index afe4246..a5022e9 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -63,7 +63,7 @@
     // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
     // is properly propagated through your change.  Not doing so will result in a loss of user
     // settings.
-    private static final int DATABASE_VERSION = 66;
+    private static final int DATABASE_VERSION = 67;
 
     private Context mContext;
 
@@ -861,6 +861,36 @@
             upgradeVersion = 66;
         }
 
+        if (upgradeVersion == 66) {
+            // This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED and
+            // NOTIFICATIONS_USE_RING_VOLUME settings are set according to device voice capability
+             db.beginTransaction();
+             try {
+                 int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) |
+                                                 (1 << AudioManager.STREAM_NOTIFICATION) |
+                                                 (1 << AudioManager.STREAM_SYSTEM) |
+                                                 (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
+                 if (!mContext.getResources().getBoolean(
+                         com.android.internal.R.bool.config_voice_capable)) {
+                     ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
+
+                     db.execSQL("DELETE FROM system WHERE name='"
+                             + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'");
+                     db.execSQL("INSERT INTO system ('name', 'value') values ('"
+                             + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "', '1')");
+                 }
+                 db.execSQL("DELETE FROM system WHERE name='"
+                         + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'");
+                 db.execSQL("INSERT INTO system ('name', 'value') values ('"
+                         + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '"
+                         + String.valueOf(ringerModeAffectedStreams) + "')");
+                 db.setTransactionSuccessful();
+             } finally {
+                 db.endTransaction();
+             }
+             upgradeVersion = 67;
+         }
+
         // *** Remember to update DATABASE_VERSION above!
 
         if (upgradeVersion != currentVersion) {
@@ -1121,12 +1151,22 @@
     
             loadVibrateSetting(db, false);
     
-            // By default, only the ring/notification, system and music streams are affected
+            // By default:
+            // - ringtones, notification, system and music streams are affected by ringer mode
+            // on non voice capable devices (tablets)
+            // - ringtones, notification and system streams are affected by ringer mode
+            // on voice capable devices (phones)
+            int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) |
+                                            (1 << AudioManager.STREAM_NOTIFICATION) |
+                                            (1 << AudioManager.STREAM_SYSTEM) |
+                                            (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
+            if (!mContext.getResources().getBoolean(
+                    com.android.internal.R.bool.config_voice_capable)) {
+                ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
+            }
             loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED,
-                    (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) |
-                    (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED) |
-                    (1 << AudioManager.STREAM_MUSIC));
-    
+                    ringerModeAffectedStreams);
+
             loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED,
                     ((1 << AudioManager.STREAM_MUSIC) |
                      (1 << AudioManager.STREAM_RING) |
@@ -1232,8 +1272,13 @@
                     R.bool.def_vibrate_in_silent);
 
             // Set notification volume to follow ringer volume by default
-            loadBooleanSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME,
-                    R.bool.def_notifications_use_ring_volume);
+            if (mContext.getResources().getBoolean(
+                    com.android.internal.R.bool.config_voice_capable)) {
+                loadBooleanSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME,
+                        R.bool.def_notifications_use_ring_volume);
+            } else {
+                loadSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME, "1");
+            }
 
             loadIntegerSetting(stmt, Settings.System.POINTER_SPEED,
                     R.integer.def_pointer_speed);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index b50fd81..f4c4bbc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -565,27 +565,33 @@
 
         final RemoteViews contentView = notification.notification.contentView;
 
-        if (false) {
+        if (DEBUG) {
             Slog.d(TAG, "old notification: when=" + oldNotification.notification.when
                     + " ongoing=" + oldNotification.isOngoing()
                     + " expanded=" + oldEntry.expanded
-                    + " contentView=" + oldContentView);
+                    + " contentView=" + oldContentView
+                    + " rowParent=" + oldEntry.row.getParent());
             Slog.d(TAG, "new notification: when=" + notification.notification.when
                     + " ongoing=" + oldNotification.isOngoing()
                     + " contentView=" + contentView);
         }
 
+
         // Can we just reapply the RemoteViews in place?  If when didn't change, the order
         // didn't change.
-        if (notification.notification.when == oldNotification.notification.when
-                && notification.isOngoing() == oldNotification.isOngoing()
-                && oldEntry.expanded != null
+        boolean contentsUnchanged = oldEntry.expanded != null
                 && contentView != null && oldContentView != null
                 && contentView.getPackage() != null
                 && oldContentView.getPackage() != null
                 && oldContentView.getPackage().equals(contentView.getPackage())
-                && oldContentView.getLayoutId() == contentView.getLayoutId()) {
-            if (SPEW) Slog.d(TAG, "reusing notification");
+                && oldContentView.getLayoutId() == contentView.getLayoutId();
+        ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent();
+        boolean orderUnchanged = notification.notification.when==oldNotification.notification.when
+                && notification.priority == oldNotification.priority;
+                // priority now encompasses isOngoing()
+        boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1;
+        if (contentsUnchanged && (orderUnchanged || isLastAnyway)) {
+            if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key);
             oldEntry.notification = notification;
             try {
                 // Reapply the RemoteViews
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index c7903c0..5dd3a6a 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -155,7 +155,9 @@
     private boolean mInetConditionChangeInFlight = false;
     private int mDefaultConnectionSequence = 0;
 
+    private Object mDnsLock = new Object();
     private int mNumDnsEntries;
+    private boolean mDnsOverridden = false;
 
     private boolean mTestMode;
     private static ConnectivityService sServiceInstance;
@@ -244,6 +246,13 @@
     private static final int EVENT_SET_DEPENDENCY_MET =
             MAX_NETWORK_STATE_TRACKER_EVENT + 10;
 
+    /**
+     * used internally to restore DNS properties back to the
+     * default network
+     */
+    private static final int EVENT_RESTORE_DNS =
+            MAX_NETWORK_STATE_TRACKER_EVENT + 11;
+
     private Handler mHandler;
 
     // list of DeathRecipients used to make sure features are turned off when
@@ -484,6 +493,7 @@
                 continue;
             }
             mCurrentLinkProperties[netType] = null;
+            if (mNetConfigs[netType].isDefault()) mNetTrackers[netType].reconnect();
         }
 
         IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
@@ -1889,6 +1899,50 @@
         mContext.sendBroadcast(intent);
     }
 
+    // Caller must grab mDnsLock.
+    private boolean updateDns(String network, Collection<InetAddress> dnses, String domains) {
+        boolean changed = false;
+        int last = 0;
+        if (dnses.size() == 0 && mDefaultDns != null) {
+            ++last;
+            String value = mDefaultDns.getHostAddress();
+            if (!value.equals(SystemProperties.get("net.dns1"))) {
+                if (DBG) {
+                    log("no dns provided for " + network + " - using " + value);
+                }
+                changed = true;
+                SystemProperties.set("net.dns1", value);
+            }
+        } else {
+            for (InetAddress dns : dnses) {
+                ++last;
+                String key = "net.dns" + last;
+                String value = dns.getHostAddress();
+                if (!changed && value.equals(SystemProperties.get(key))) {
+                    continue;
+                }
+                if (DBG) {
+                    log("adding dns " + value + " for " + network);
+                }
+                changed = true;
+                SystemProperties.set(key, value);
+            }
+        }
+        for (int i = last + 1; i <= mNumDnsEntries; ++i) {
+            String key = "net.dns" + i;
+            if (DBG) log("erasing " + key);
+            changed = true;
+            SystemProperties.set(key, "");
+        }
+        mNumDnsEntries = last;
+
+        if (!domains.equals(SystemProperties.get("net.dns.search"))) {
+            SystemProperties.set("net.dns.search", domains);
+            changed = true;
+        }
+        return changed;
+    }
+
     private void handleDnsConfigurationChange(int netType) {
         // add default net's dns entries
         NetworkStateTracker nt = mNetTrackers[netType];
@@ -1898,40 +1952,12 @@
             Collection<InetAddress> dnses = p.getDnses();
             boolean changed = false;
             if (mNetConfigs[netType].isDefault()) {
-                int j = 1;
-                if (dnses.size() == 0 && mDefaultDns != null) {
-                    String dnsString = mDefaultDns.getHostAddress();
-                    if (!dnsString.equals(SystemProperties.get("net.dns1"))) {
-                        if (DBG) {
-                            log("no dns provided - using " + dnsString);
-                        }
-                        changed = true;
-                        SystemProperties.set("net.dns1", dnsString);
-                    }
-                    j++;
-                } else {
-                    for (InetAddress dns : dnses) {
-                        String dnsString = dns.getHostAddress();
-                        if (!changed && dnsString.equals(SystemProperties.get("net.dns" + j))) {
-                            j++;
-                            continue;
-                        }
-                        if (DBG) {
-                            log("adding dns " + dns + " for " +
-                                    nt.getNetworkInfo().getTypeName());
-                        }
-                        changed = true;
-                        SystemProperties.set("net.dns" + j++, dnsString);
+                String network = nt.getNetworkInfo().getTypeName();
+                synchronized (mDnsLock) {
+                    if (!mDnsOverridden) {
+                        changed = updateDns(network, dnses, "");
                     }
                 }
-                for (int k=j ; k<mNumDnsEntries; k++) {
-                    if (changed || !TextUtils.isEmpty(SystemProperties.get("net.dns" + k))) {
-                        if (DBG) log("erasing net.dns" + k);
-                        changed = true;
-                        SystemProperties.set("net.dns" + k, "");
-                    }
-                }
-                mNumDnsEntries = j;
             } else {
                 // set per-pid dns for attached secondary nets
                 List pids = mNetRequestersPids[netType];
@@ -2138,6 +2164,13 @@
                     handleSetDependencyMet(msg.arg2, met);
                     break;
                 }
+                case EVENT_RESTORE_DNS:
+                {
+                    if (mActiveDefaultNetwork != -1) {
+                        handleDnsConfigurationChange(mActiveDefaultNetwork);
+                    }
+                    break;
+                }
             }
         }
     }
@@ -2585,12 +2618,57 @@
         private VpnCallback() {
         }
 
-        public synchronized void override(List<String> dnsServers, List<String> searchDomains) {
-            // TODO: override DNS servers and http proxy.
+        public void override(List<String> dnsServers, List<String> searchDomains) {
+            if (dnsServers == null) {
+                restore();
+                return;
+            }
+
+            // Convert DNS servers into addresses.
+            List<InetAddress> addresses = new ArrayList<InetAddress>();
+            for (String address : dnsServers) {
+                // Double check the addresses and remove invalid ones.
+                try {
+                    addresses.add(InetAddress.parseNumericAddress(address));
+                } catch (Exception e) {
+                    // ignore
+                }
+            }
+            if (addresses.isEmpty()) {
+                restore();
+                return;
+            }
+
+            // Concatenate search domains into a string.
+            StringBuilder buffer = new StringBuilder();
+            if (searchDomains != null) {
+                for (String domain : searchDomains) {
+                    buffer.append(domain).append(' ');
+                }
+            }
+            String domains = buffer.toString().trim();
+
+            // Apply DNS changes.
+            boolean changed = false;
+            synchronized (mDnsLock) {
+                changed = updateDns("VPN", addresses, domains);
+                mDnsOverridden = true;
+            }
+            if (changed) {
+                bumpDns();
+            }
+
+            // TODO: temporarily remove http proxy?
         }
 
-        public synchronized void restore() {
-            // TODO: restore VPN changes.
+        public void restore() {
+            synchronized (mDnsLock) {
+                if (!mDnsOverridden) {
+                    return;
+                }
+                mDnsOverridden = false;
+            }
+            mHandler.sendEmptyMessage(EVENT_RESTORE_DNS);
         }
     }
 }
diff --git a/tests/BiDiTests/Android b/tests/BiDiTests/Android
deleted file mode 100644
index e69de29..0000000
--- a/tests/BiDiTests/Android
+++ /dev/null
diff --git a/tests/BiDiTests/Android.mk b/tests/BiDiTests/Android-private.mk
similarity index 100%
rename from tests/BiDiTests/Android.mk
rename to tests/BiDiTests/Android-private.mk
diff --git a/tests/BiDiTests/new-attributes.txt b/tests/BiDiTests/new-attributes.txt
new file mode 100644
index 0000000..57854cc
--- /dev/null
+++ b/tests/BiDiTests/new-attributes.txt
@@ -0,0 +1,9 @@
+  <public type="attr" name="layoutDirection" />
+
+  <public type="attr" name="layout_marginStart"/>
+  <public type="attr" name="layout_marginEnd"/>
+
+  <public type="attr" name="paddingStart"/>
+  <public type="attr" name="paddingEnd"/>
+
+  <public type="attr" name="textDirection"/>