Merge "Fix volume panel shadows" into pi-dev
diff --git a/api/current.txt b/api/current.txt
index eac2168..dc0802d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -41685,10 +41685,7 @@
     field public static final java.lang.String KEY_CONFIG_PLANS_PACKAGE_OVERRIDE_STRING = "config_plans_package_override_string";
     field public static final java.lang.String KEY_CONFIG_TELEPHONY_USE_OWN_NUMBER_FOR_VOICEMAIL_BOOL = "config_telephony_use_own_number_for_voicemail_bool";
     field public static final java.lang.String KEY_CSP_ENABLED_BOOL = "csp_enabled_bool";
-    field public static final java.lang.String KEY_DATA_LIMIT_NOTIFICATION_BOOL = "data_limit_notification_bool";
     field public static final java.lang.String KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG = "data_limit_threshold_bytes_long";
-    field public static final java.lang.String KEY_DATA_RAPID_NOTIFICATION_BOOL = "data_rapid_notification_bool";
-    field public static final java.lang.String KEY_DATA_WARNING_NOTIFICATION_BOOL = "data_warning_notification_bool";
     field public static final java.lang.String KEY_DATA_WARNING_THRESHOLD_BYTES_LONG = "data_warning_threshold_bytes_long";
     field public static final java.lang.String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
     field public static final java.lang.String KEY_DEFAULT_VM_NUMBER_STRING = "default_vm_number_string";
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 5461c0c..0f2a11a 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -86,6 +86,7 @@
     ParceledListSlice getNotificationChannelGroups(String pkg);
     boolean onlyHasDefaultChannel(String pkg, int uid);
     ParceledListSlice getRecentNotifyingAppsForUser(int userId);
+    int getBlockedAppCount(int userId);
 
     // TODO: Remove this when callers have been migrated to the equivalent
     // INotificationListener method.
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 2b4f420..8ee443b 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3115,7 +3115,6 @@
         private int mTextColorsAreForBackground = COLOR_INVALID;
         private int mPrimaryTextColor = COLOR_INVALID;
         private int mSecondaryTextColor = COLOR_INVALID;
-        private int mActionBarColor = COLOR_INVALID;
         private int mBackgroundColor = COLOR_INVALID;
         private int mForegroundColor = COLOR_INVALID;
         /**
@@ -4359,16 +4358,6 @@
             return mSecondaryTextColor;
         }
 
-        private int getActionBarColor() {
-            ensureColors();
-            return mActionBarColor;
-        }
-
-        private int getActionBarColorDeEmphasized() {
-            int backgroundColor = getBackgroundColor();
-            return NotificationColorUtil.getShiftedColor(backgroundColor, 12);
-        }
-
         private void setTextViewColorSecondary(RemoteViews contentView, int id) {
             ensureColors();
             contentView.setTextColor(id, mSecondaryTextColor);
@@ -4378,7 +4367,6 @@
             int backgroundColor = getBackgroundColor();
             if (mPrimaryTextColor == COLOR_INVALID
                     || mSecondaryTextColor == COLOR_INVALID
-                    || mActionBarColor == COLOR_INVALID
                     || mTextColorsAreForBackground != backgroundColor) {
                 mTextColorsAreForBackground = backgroundColor;
                 if (!hasForegroundColor() || !isColorized()) {
@@ -4451,8 +4439,6 @@
                         }
                     }
                 }
-                mActionBarColor = NotificationColorUtil.resolveActionBarColor(mContext,
-                        backgroundColor);
             }
         }
 
@@ -4769,8 +4755,8 @@
                     validRemoteInput |= actionHasValidInput;
 
                     final RemoteViews button = generateActionButton(action, emphazisedMode,
-                            i % 2 != 0, p.ambient);
-                    if (actionHasValidInput) {
+                            p.ambient);
+                    if (actionHasValidInput && !emphazisedMode) {
                         // Clear the drawable
                         button.setInt(R.id.action0, "setBackgroundResource", 0);
                     }
@@ -5077,7 +5063,7 @@
         }
 
         private RemoteViews generateActionButton(Action action, boolean emphazisedMode,
-                boolean oddAction, boolean ambient) {
+                boolean ambient) {
             final boolean tombstone = (action.actionIntent == null);
             RemoteViews button = new BuilderRemoteViews(mContext.getApplicationInfo(),
                     emphazisedMode ? getEmphasizedActionLayoutResource()
@@ -5090,35 +5076,42 @@
             if (action.mRemoteInputs != null) {
                 button.setRemoteInputs(R.id.action0, action.mRemoteInputs);
             }
-            // TODO: handle emphasized mode / actions right
             if (emphazisedMode) {
                 // change the background bgColor
-                int bgColor;
-                if (isColorized()) {
-                    bgColor = oddAction ? getActionBarColor() : getActionBarColorDeEmphasized();
-                } else {
-                    bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
-                            : R.color.notification_action_list_dark);
-                }
-                button.setDrawableTint(R.id.button_holder, true,
-                        bgColor, PorterDuff.Mode.SRC_ATOP);
                 CharSequence title = action.title;
                 ColorStateList[] outResultColor = null;
+                int background = resolveBackgroundColor();
                 if (isLegacy()) {
                     title = NotificationColorUtil.clearColorSpans(title);
                 } else {
                     outResultColor = new ColorStateList[1];
-                    title = ensureColorSpanContrast(title, bgColor, outResultColor);
+                    title = ensureColorSpanContrast(title, background, outResultColor);
                 }
                 button.setTextViewText(R.id.action0, processTextSpans(title));
                 setTextViewColorPrimary(button, R.id.action0);
-                if (outResultColor != null && outResultColor[0] != null) {
-                    // We need to set the text color as well since changing a text to uppercase
-                    // clears its spans.
-                    button.setTextColor(R.id.action0, outResultColor[0]);
+                int rippleColor;
+                boolean hasColorOverride = outResultColor != null && outResultColor[0] != null;
+                if (hasColorOverride) {
+                    // There's a span spanning the full text, let's take it and use it as the
+                    // background color
+                    background = outResultColor[0].getDefaultColor();
+                    int textColor = NotificationColorUtil.resolvePrimaryColor(mContext,
+                            background);
+                    button.setTextColor(R.id.action0, textColor);
+                    rippleColor = textColor;
                 } else if (mN.color != COLOR_DEFAULT && !isColorized() && mTintActionButtons) {
-                    button.setTextColor(R.id.action0,resolveContrastColor());
+                    rippleColor = resolveContrastColor();
+                    button.setTextColor(R.id.action0, rippleColor);
+                } else {
+                    rippleColor = getPrimaryTextColor();
                 }
+                // We only want about 20% alpha for the ripple
+                rippleColor = (rippleColor & 0x00ffffff) | 0x33000000;
+                button.setColorStateList(R.id.action0, "setRippleColor",
+                        ColorStateList.valueOf(rippleColor));
+                button.setColorStateList(R.id.action0, "setButtonBackground",
+                        ColorStateList.valueOf(background));
+                button.setBoolean(R.id.action0, "setHasStroke", !hasColorOverride);
             } else {
                 button.setTextViewText(R.id.action0, processTextSpans(
                         processLegacyText(action.title)));
@@ -5168,31 +5161,35 @@
                             }
                             textColor = new ColorStateList(textColor.getStates().clone(),
                                     newColors);
+                            if (fullLength) {
+                                outResultColor[0] = textColor;
+                                // Let's drop the color from the span
+                                textColor = null;
+                            }
                             resultSpan = new TextAppearanceSpan(
                                     originalSpan.getFamily(),
                                     originalSpan.getTextStyle(),
                                     originalSpan.getTextSize(),
                                     textColor,
                                     originalSpan.getLinkTextColor());
-                            if (fullLength) {
-                                outResultColor[0] = new ColorStateList(
-                                        textColor.getStates().clone(), newColors);
-                            }
                         }
                     } else if (resultSpan instanceof ForegroundColorSpan) {
                         ForegroundColorSpan originalSpan = (ForegroundColorSpan) resultSpan;
                         int foregroundColor = originalSpan.getForegroundColor();
                         foregroundColor = NotificationColorUtil.ensureLargeTextContrast(
                                 foregroundColor, background, mInNightMode);
-                        resultSpan = new ForegroundColorSpan(foregroundColor);
                         if (fullLength) {
                             outResultColor[0] = ColorStateList.valueOf(foregroundColor);
+                            resultSpan = null;
+                        } else {
+                            resultSpan = new ForegroundColorSpan(foregroundColor);
                         }
                     } else {
                         resultSpan = span;
                     }
-
-                    builder.setSpan(resultSpan, spanStart, spanEnd, ss.getSpanFlags(span));
+                    if (resultSpan != null) {
+                        builder.setSpan(resultSpan, spanStart, spanEnd, ss.getSpanFlags(span));
+                    }
                 }
                 return builder;
             }
@@ -5523,6 +5520,18 @@
             }
         }
 
+        /**
+         * Same as getBackgroundColor but also resolved the default color to the background.
+         */
+        private int resolveBackgroundColor() {
+            int backgroundColor = getBackgroundColor();
+            if (backgroundColor == COLOR_DEFAULT) {
+                backgroundColor = mContext.getColor(
+                        com.android.internal.R.color.notification_material_background_color);
+            }
+            return backgroundColor;
+        }
+
         private boolean isColorized() {
             return mN.isColorized();
         }
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java
index 3df4336..71edc8a 100644
--- a/core/java/android/bluetooth/BluetoothGatt.java
+++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -1514,22 +1514,24 @@
      * @return true, if the request is send to the Bluetooth stack.
      * @hide
      */
-    public boolean requestLeConnectionUpdate(int minConnectionInterval,
-                                                 int maxConnectionInterval,
-                                                 int slaveLatency, int supervisionTimeout) {
+    public boolean requestLeConnectionUpdate(int minConnectionInterval, int maxConnectionInterval,
+                                             int slaveLatency, int supervisionTimeout,
+                                             int minConnectionEventLen, int maxConnectionEventLen) {
         if (DBG) {
             Log.d(TAG, "requestLeConnectionUpdate() - min=(" + minConnectionInterval
-                       + ")" + (1.25 * minConnectionInterval)
-                       + "msec, max=(" + maxConnectionInterval + ")"
+                        + ")" + (1.25 * minConnectionInterval)
+                        + "msec, max=(" + maxConnectionInterval + ")"
                         + (1.25 * maxConnectionInterval) + "msec, latency=" + slaveLatency
-                       + ", timeout=" + supervisionTimeout + "msec");
+                        + ", timeout=" + supervisionTimeout + "msec" + ", min_ce="
+                        + minConnectionEventLen + ", max_ce=" + maxConnectionEventLen);
         }
         if (mService == null || mClientIf == 0) return false;
 
         try {
             mService.leConnectionUpdate(mClientIf, mDevice.getAddress(),
-                                               minConnectionInterval, maxConnectionInterval,
-                                               slaveLatency, supervisionTimeout);
+                                        minConnectionInterval, maxConnectionInterval,
+                                        slaveLatency, supervisionTimeout,
+                                        minConnectionEventLen, maxConnectionEventLen);
         } catch (RemoteException e) {
             Log.e(TAG, "", e);
             return false;
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 08513aa..a34bd09 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -3000,6 +3000,21 @@
     }
 
     /**
+     * Call a method taking one ColorStateList on a view in the layout for this RemoteViews.
+     *
+     * @param viewId The id of the view on which to call the method.
+     * @param methodName The name of the method to call.
+     * @param value The value to pass to the method.
+     *
+     * @hide
+     */
+    public void setColorStateList(int viewId, String methodName, ColorStateList value) {
+        addAction(new ReflectionAction(viewId, methodName, ReflectionAction.COLOR_STATE_LIST,
+                value));
+    }
+
+
+    /**
      * Call a method taking one long on a view in the layout for this RemoteViews.
      *
      * @param viewId The id of the view on which to call the method.
diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java
index 577fa17..0f13078 100644
--- a/core/java/com/android/internal/util/NotificationColorUtil.java
+++ b/core/java/com/android/internal/util/NotificationColorUtil.java
@@ -558,13 +558,6 @@
         }
     }
 
-    public static int resolveActionBarColor(Context context, int backgroundColor) {
-        if (backgroundColor == Notification.COLOR_DEFAULT) {
-            return context.getColor(com.android.internal.R.color.notification_action_list);
-        }
-        return getShiftedColor(backgroundColor, 7);
-    }
-
     /**
      * Get a color that stays in the same tint, but darkens or lightens it by a certain
      * amount.
diff --git a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java
new file mode 100644
index 0000000..5213746
--- /dev/null
+++ b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 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.internal.widget;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.drawable.DrawableWrapper;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.InsetDrawable;
+import android.graphics.drawable.RippleDrawable;
+import android.util.AttributeSet;
+import android.view.RemotableViewMethod;
+import android.widget.Button;
+import android.widget.RemoteViews;
+
+/**
+ * A button implementation for the emphasized notification style.
+ *
+ * @hide
+ */
+@RemoteViews.RemoteView
+public class EmphasizedNotificationButton extends Button {
+    private final RippleDrawable mRipple;
+    private final int mStrokeWidth;
+    private final int mStrokeColor;
+
+    public EmphasizedNotificationButton(Context context) {
+        this(context, null);
+    }
+
+    public EmphasizedNotificationButton(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public EmphasizedNotificationButton(Context context, AttributeSet attrs, int defStyleAttr) {
+        this(context, attrs, defStyleAttr, 0);
+    }
+
+    public EmphasizedNotificationButton(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+        DrawableWrapper background = (DrawableWrapper) getBackground().mutate();
+        mRipple = (RippleDrawable) background.getDrawable();
+        mStrokeWidth = getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.emphasized_button_stroke_width);
+        mStrokeColor = getContext().getColor(com.android.internal.R.color.material_grey_300);
+        mRipple.mutate();
+    }
+
+    @RemotableViewMethod
+    public void setRippleColor(ColorStateList color) {
+        mRipple.setColor(color);
+        invalidate();
+    }
+
+    @RemotableViewMethod
+    public void setButtonBackground(ColorStateList color) {
+        GradientDrawable inner = (GradientDrawable) mRipple.getDrawable(0);
+        inner.setColor(color);
+        invalidate();
+    }
+
+    @RemotableViewMethod
+    public void setHasStroke(boolean hasStroke) {
+        GradientDrawable inner = (GradientDrawable) mRipple.getDrawable(0);
+        inner.setStroke(hasStroke ? mStrokeWidth : 0, mStrokeColor);
+        invalidate();
+    }
+}
diff --git a/core/java/com/android/internal/widget/NotificationActionListLayout.java b/core/java/com/android/internal/widget/NotificationActionListLayout.java
index e013553..0482f6c 100644
--- a/core/java/com/android/internal/widget/NotificationActionListLayout.java
+++ b/core/java/com/android/internal/widget/NotificationActionListLayout.java
@@ -16,17 +16,15 @@
 
 package com.android.internal.widget;
 
-import android.annotation.Nullable;
 import android.content.Context;
-import android.content.res.Resources;
 import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
 import android.graphics.drawable.RippleDrawable;
 import android.util.AttributeSet;
 import android.util.Pair;
 import android.view.Gravity;
 import android.view.RemotableViewMethod;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.LinearLayout;
 import android.widget.RemoteViews;
 import android.widget.TextView;
@@ -45,9 +43,11 @@
     private int mTotalWidth = 0;
     private ArrayList<Pair<Integer, TextView>> mMeasureOrderTextViews = new ArrayList<>();
     private ArrayList<View> mMeasureOrderOther = new ArrayList<>();
-    private boolean mMeasureLinearly;
-    private int mDefaultPaddingEnd;
-    private Drawable mDefaultBackground;
+    private boolean mEmphasizedMode;
+    private int mDefaultPaddingBottom;
+    private int mDefaultPaddingTop;
+    private int mEmphasizedHeight;
+    private int mRegularHeight;
 
     public NotificationActionListLayout(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
@@ -68,7 +68,7 @@
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        if (mMeasureLinearly) {
+        if (mEmphasizedMode) {
             super.onMeasure(widthMeasureSpec, heightMeasureSpec);
             return;
         }
@@ -219,7 +219,7 @@
 
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
-        if (mMeasureLinearly) {
+        if (mEmphasizedMode) {
             super.onLayout(changed, left, top, right, bottom);
             return;
         }
@@ -280,8 +280,21 @@
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
-        mDefaultPaddingEnd = getPaddingEnd();
-        mDefaultBackground = getBackground();
+        mDefaultPaddingBottom = getPaddingBottom();
+        mDefaultPaddingTop = getPaddingTop();
+        updateHeights();
+    }
+
+    private void updateHeights() {
+        int paddingTop = getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.notification_content_margin);
+        // same padding on bottom and at end
+        int paddingBottom = getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.notification_content_margin_end);
+        mEmphasizedHeight = paddingBottom + paddingTop + getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.notification_action_emphasized_height);
+        mRegularHeight = getResources().getDimensionPixelSize(
+                com.android.internal.R.dimen.notification_action_list_height);
     }
 
     /**
@@ -291,11 +304,38 @@
      */
     @RemotableViewMethod
     public void setEmphasizedMode(boolean emphasizedMode) {
-        mMeasureLinearly = emphasizedMode;
-        setPaddingRelative(getPaddingStart(), getPaddingTop(),
-                emphasizedMode ? 0 : mDefaultPaddingEnd, getPaddingBottom());
-        setBackground(emphasizedMode ? null : mDefaultBackground);
-        requestLayout();
+        mEmphasizedMode = emphasizedMode;
+        int height;
+        if (emphasizedMode) {
+            int paddingTop = getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.notification_content_margin);
+            // same padding on bottom and at end
+            int paddingBottom = getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.notification_content_margin_end);
+            height = mEmphasizedHeight;
+            int buttonPaddingInternal = getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.button_inset_vertical_material);
+            setPaddingRelative(getPaddingStart(),
+                    paddingTop - buttonPaddingInternal,
+                    getPaddingEnd(),
+                    paddingBottom - buttonPaddingInternal);
+        } else {
+            setPaddingRelative(getPaddingStart(),
+                    mDefaultPaddingTop,
+                    getPaddingEnd(),
+                    mDefaultPaddingBottom);
+            height = mRegularHeight;
+        }
+        ViewGroup.LayoutParams layoutParams = getLayoutParams();
+        layoutParams.height = height;
+        setLayoutParams(layoutParams);
+    }
+
+    public int getExtraMeasureHeight() {
+        if (mEmphasizedMode) {
+            return mEmphasizedHeight - mRegularHeight;
+        }
+        return 0;
     }
 
     public static final Comparator<Pair<Integer, TextView>> MEASURE_ORDER_COMPARATOR
diff --git a/core/res/res/anim/flat_button_state_list_anim_material.xml b/core/res/res/anim/flat_button_state_list_anim_material.xml
new file mode 100644
index 0000000..266f14a
--- /dev/null
+++ b/core/res/res/anim/flat_button_state_list_anim_material.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2018 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
+  -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:state_enabled="true">
+        <set>
+            <objectAnimator android:propertyName="translationZ"
+                            android:duration="@integer/button_pressed_animation_duration"
+                            android:valueTo="1dp"
+                            android:valueType="floatType"/>
+        </set>
+    </item>
+    <!-- base state -->
+    <item android:state_enabled="true">
+        <set>
+            <objectAnimator android:propertyName="translationZ"
+                            android:duration="@integer/button_pressed_animation_duration"
+                            android:valueTo="0"
+                            android:startDelay="@integer/button_pressed_animation_delay"
+                            android:valueType="floatType"/>
+        </set>
+    </item>
+    <item>
+        <set>
+            <objectAnimator android:propertyName="translationZ"
+                            android:duration="0"
+                            android:valueTo="0"
+                            android:valueType="floatType"/>
+        </set>
+    </item>
+</selector>
\ No newline at end of file
diff --git a/core/res/res/drawable/btn_notification_emphasized.xml b/core/res/res/drawable/btn_notification_emphasized.xml
new file mode 100644
index 0000000..1a574fe
--- /dev/null
+++ b/core/res/res/drawable/btn_notification_emphasized.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2018 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
+  -->
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+       android:insetLeft="@dimen/button_inset_horizontal_material"
+       android:insetTop="@dimen/button_inset_vertical_material"
+       android:insetRight="@dimen/button_inset_horizontal_material"
+       android:insetBottom="@dimen/button_inset_vertical_material">
+    <ripple android:color="?attr/colorControlHighlight">
+        <item>
+            <shape android:shape="rectangle">
+                <corners android:radius="?attr/buttonCornerRadius" />
+                <padding android:left="@dimen/button_padding_horizontal_material"
+                         android:top="@dimen/button_padding_vertical_material"
+                         android:right="@dimen/button_padding_horizontal_material"
+                         android:bottom="@dimen/button_padding_vertical_material" />
+                <solid android:color="@color/white" />
+                <stroke android:width="@dimen/emphasized_button_stroke_width"
+                        android:color="@color/material_grey_300"/>
+            </shape>
+        </item>
+    </ripple>
+</inset>
diff --git a/core/res/res/layout/notification_material_action_emphasized.xml b/core/res/res/layout/notification_material_action_emphasized.xml
index 1e364cc..a6b7b38 100644
--- a/core/res/res/layout/notification_material_action_emphasized.xml
+++ b/core/res/res/layout/notification_material_action_emphasized.xml
@@ -14,21 +14,16 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/button_holder"
+<com.android.internal.widget.EmphasizedNotificationButton
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    style="@style/NotificationEmphasizedAction"
+    android:id="@+id/action0"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:layout_marginStart="12dp"
     android:layout_weight="1"
-    android:background="#ff000000">
-    <Button
-        style="@android:style/Widget.Material.Light.Button.Borderless.Small"
-        android:id="@+id/action0"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center"
-        android:textColor="@color/notification_default_color"
-        android:singleLine="true"
-        android:ellipsize="end"
-        android:background="@drawable/notification_material_action_background"
-        />
-</FrameLayout>
+    android:gravity="center"
+    android:textColor="@color/notification_default_color"
+    android:singleLine="true"
+    android:ellipsize="end"
+/>
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index c63f319..9215f3f 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -148,7 +148,6 @@
     <color name="notification_progress_background_color">@color/secondary_text_material_light</color>
 
     <color name="notification_action_list">#ffeeeeee</color>
-    <color name="notification_action_list_dark">#ffe0e0e0</color>
 
     <!-- Keyguard colors -->
     <color name="keyguard_avatar_frame_color">#ffffffff</color>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 0581856..2aa40fd 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -182,6 +182,12 @@
     <!-- The height of the notification action list -->
     <dimen name="notification_action_list_height">60dp</dimen>
 
+    <!-- The height of the notification action list -->
+    <dimen name="notification_action_emphasized_height">48dp</dimen>
+
+    <!-- Size of the stroke with for the emphasized notification button style -->
+    <dimen name="emphasized_button_stroke_width">1dp</dimen>
+
     <!-- height of the content margin to accomodate for the header -->
     <dimen name="notification_content_margin_top">46dp</dimen>
 
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index e14aa14..984461b 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1510,4 +1510,10 @@
         <item name="gravity">top</item>
     </style>
 
+    <!-- Colored bordered ink button -->
+    <style name="NotificationEmphasizedAction" parent="Widget.Material.Button">
+        <item name="background">@drawable/btn_notification_emphasized</item>
+        <item name="stateListAnimator">@anim/flat_button_state_list_anim_material</item>
+    </style>
+
 </resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index b6f0b70..129a952 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2814,7 +2814,6 @@
 
   <java-symbol type="color" name="notification_action_list" />
   <java-symbol type="color" name="notification_material_background_color" />
-  <java-symbol type="color" name="notification_action_list_dark" />
 
   <!-- Resolver target actions -->
   <java-symbol type="array" name="resolver_target_actions_pin" />
@@ -2864,6 +2863,7 @@
   <java-symbol type="dimen" name="input_extract_action_button_height" />
 
   <java-symbol type="dimen" name="notification_action_list_height" />
+  <java-symbol type="dimen" name="notification_action_emphasized_height" />
 
   <!-- TV Remote Service package -->
   <java-symbol type="string" name="config_tvRemoteServicePackage" />
@@ -2889,8 +2889,6 @@
   <!-- Used internally for assistant to launch activity transitions -->
   <java-symbol type="id" name="cross_task_transition" />
 
-  <java-symbol type="id" name="button_holder" />
-
   <java-symbol type="bool" name="config_useRoundIcon" />
 
   <!-- For System navigation keys -->
@@ -3225,6 +3223,9 @@
   <java-symbol type="drawable" name="stat_sys_vitals" />
 
   <java-symbol type="color" name="text_color_primary" />
+  <java-symbol type="color" name="material_grey_300" />
+  <java-symbol type="dimen" name="emphasized_button_stroke_width" />
+  <java-symbol type="dimen" name="button_inset_vertical_material" />
 
   <java-symbol type="array" name="config_batteryPackageTypeSystem" />
   <java-symbol type="array" name="config_batteryPackageTypeService" />
@@ -3271,7 +3272,6 @@
   <java-symbol type="id" name="remote_input_progress" />
   <java-symbol type="id" name="remote_input_send" />
   <java-symbol type="id" name="remote_input" />
-  <java-symbol type="dimen" name="notification_content_margin" />
   <java-symbol type="dimen" name="slice_shortcut_size" />
   <java-symbol type="dimen" name="slice_icon_size" />
   <java-symbol type="dimen" name="slice_padding" />
diff --git a/media/java/android/media/update/ApiLoader.java b/media/java/android/media/update/ApiLoader.java
index 6f82f68..a7eb30d 100644
--- a/media/java/android/media/update/ApiLoader.java
+++ b/media/java/android/media/update/ApiLoader.java
@@ -16,68 +16,14 @@
 
 package android.media.update;
 
-import android.app.ActivityManager;
-import android.app.AppGlobals;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.Build;
-import android.os.RemoteException;
-import android.os.UserHandle;
-
-import com.android.internal.annotations.GuardedBy;
-
-import dalvik.system.PathClassLoader;
-
-import java.io.File;
-
 /**
  * @hide
  */
 public final class ApiLoader {
-    @GuardedBy("this")
-    private static StaticProvider sMediaUpdatable;
-
-    private static final String UPDATE_PACKAGE = "com.android.media.update";
-    private static final String UPDATE_CLASS = "com.android.media.update.ApiFactory";
-    private static final String UPDATE_METHOD = "initialize";
-    private static final boolean REGISTER_UPDATE_DEPENDENCY = true;
-
     private ApiLoader() { }
 
     public static StaticProvider getProvider() {
-        if (sMediaUpdatable != null) return sMediaUpdatable;
-
-        try {
-            return getMediaUpdatable();
-        } catch (RemoteException e) {
-            throw e.rethrowFromSystemServer();
-        } catch (NameNotFoundException | ReflectiveOperationException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    // TODO This method may do I/O; Ensure it does not violate (emit warnings in) strict mode.
-    private static synchronized StaticProvider getMediaUpdatable()
-            throws NameNotFoundException, ReflectiveOperationException, RemoteException {
-        if (sMediaUpdatable != null) return sMediaUpdatable;
-
-        // TODO Figure out when to use which package (query media update service)
-        int flags = Build.IS_DEBUGGABLE ? 0 : PackageManager.MATCH_FACTORY_ONLY;
-        flags |= PackageManager.GET_SHARED_LIBRARY_FILES;
-        ApplicationInfo ai = AppGlobals.getPackageManager().getApplicationInfo(
-                UPDATE_PACKAGE, flags, UserHandle.myUserId());
-
-        if (REGISTER_UPDATE_DEPENDENCY) {
-            // Register a dependency to the updatable in order to be killed during updates
-            ActivityManager.getService().addPackageDependency(ai.packageName);
-        }
-
-        ClassLoader classLoader = new PathClassLoader(ai.sourceDir,
-                ai.nativeLibraryDir + File.pathSeparator + System.getProperty("java.library.path"),
-                ClassLoader.getSystemClassLoader().getParent());
-        return sMediaUpdatable = (StaticProvider) classLoader.loadClass(UPDATE_CLASS)
-                .getMethod(UPDATE_METHOD, ApplicationInfo.class).invoke(null, ai);
+        throw new RuntimeException("Use MediaSession/Browser instead of"
+                + " hidden MediaSession2/Browser2 APIs.");
     }
 }
diff --git a/packages/SystemUI/res/drawable/ic_volume_accessibility.xml b/packages/SystemUI/res/drawable/ic_volume_accessibility.xml
index 88fb2d2..71376d5 100644
--- a/packages/SystemUI/res/drawable/ic_volume_accessibility.xml
+++ b/packages/SystemUI/res/drawable/ic_volume_accessibility.xml
@@ -15,8 +15,8 @@
   -->
 
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="32dp"
-        android:height="32dp"
+        android:width="24dp"
+        android:height="24dp"
         android:viewportWidth="24.0"
         android:viewportHeight="24.0"
         android:tint="?android:attr/colorControlNormal">
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 9ced28e..e6694e9 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -946,7 +946,7 @@
     <!-- Fingerprint Dialog values -->
     <dimen name="fingerprint_dialog_fp_icon_size">64dp</dimen>
     <dimen name="fingerprint_dialog_animation_translation_offset">350dp</dimen>
-    <dimen name="fingerprint_dialog_corner_size">2dp</dimen>
+    <dimen name="fingerprint_dialog_corner_size">4dp</dimen>
 
     <!-- Wireless Charging Animation values -->
     <dimen name="wireless_charging_dots_radius_start">0dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 8030bde..e527be1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -239,7 +239,9 @@
             }
         }
         if (mHeadsUpChild != null) {
-            int size = Math.min(maxSize, mHeadsUpHeight);
+            int maxHeight = mHeadsUpHeight;
+            maxHeight += mHeadsUpWrapper.getExtraMeasureHeight();
+            int size = Math.min(maxSize, maxHeight);
             ViewGroup.LayoutParams layoutParams = mHeadsUpChild.getLayoutParams();
             boolean useExactly = false;
             if (layoutParams.height >= 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
index 28beb21..5f7b638 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
@@ -25,6 +25,7 @@
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
+import com.android.internal.widget.NotificationActionListLayout;
 import com.android.systemui.statusbar.CrossFadeHelper;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.TransformableView;
@@ -47,6 +48,7 @@
 
     private int mContentHeight;
     private int mMinHeightHint;
+    private NotificationActionListLayout mActions;
 
     protected NotificationTemplateViewWrapper(Context ctx, View view,
             ExpandableNotificationRow row) {
@@ -133,6 +135,7 @@
             mProgressBar = null;
         }
         mActionsContainer = mView.findViewById(com.android.internal.R.id.actions_container);
+        mActions = mView.findViewById(com.android.internal.R.id.actions);
         mReplyAction = mView.findViewById(com.android.internal.R.id.reply_icon_action);
     }
 
@@ -284,4 +287,13 @@
                     - getHeaderTranslation());
         }
     }
+
+    @Override
+    public int getExtraMeasureHeight() {
+        int extra = 0;
+        if (mActions != null) {
+            extra = mActions.getExtraMeasureHeight();
+        }
+        return extra + super.getExtraMeasureHeight();
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
index 873f088..b09df15 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
@@ -205,4 +205,12 @@
 
     public void setHeaderVisibleAmount(float headerVisibleAmount) {
     }
+
+    /**
+     * Get the extra height that needs to be added to this view, such that it can be measured
+     * normally.
+     */
+    public int getExtraMeasureHeight() {
+        return 0;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 00874e3..e801607 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -45,10 +45,8 @@
 import android.graphics.Color;
 import android.graphics.PixelFormat;
 import android.graphics.drawable.ColorDrawable;
-import android.media.AudioAttributes;
 import android.media.AudioManager;
 import android.media.AudioSystem;
-import android.media.MediaPlayer;
 import android.os.Debug;
 import android.os.Handler;
 import android.os.Looper;
@@ -132,8 +130,8 @@
     private final AccessibilityManagerWrapper mAccessibilityMgr;
     private final Object mSafetyWarningLock = new Object();
     private final Accessibility mAccessibility = new Accessibility();
-    private final ColorStateList mActiveSliderTint;
-    private final ColorStateList mInactiveSliderTint;
+    private final ColorStateList mActiveTint;
+    private final ColorStateList mInactiveTint;
     private final Vibrator mVibrator;
 
     private boolean mShowing;
@@ -152,8 +150,8 @@
         mController = Dependency.get(VolumeDialogController.class);
         mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
         mAccessibilityMgr = Dependency.get(AccessibilityManagerWrapper.class);
-        mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext));
-        mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive);
+        mActiveTint = ColorStateList.valueOf(Utils.getColorAccent(mContext));
+        mInactiveTint = loadColorStateList(R.color.volume_slider_inactive);
         mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
         mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
     }
@@ -614,7 +612,7 @@
             final boolean shouldBeVisible = shouldBeVisibleH(row, activeRow);
             Util.setVisOrGone(row.view, shouldBeVisible);
             if (row.view.isShown()) {
-                updateVolumeRowSliderTintH(row, isActive);
+                updateVolumeRowTintH(row, isActive);
             }
         }
     }
@@ -848,21 +846,22 @@
         updateVolumeRowSliderH(row, enableSlider, vlevel);
     }
 
-    private void updateVolumeRowSliderTintH(VolumeRow row, boolean isActive) {
+    private void updateVolumeRowTintH(VolumeRow row, boolean isActive) {
         if (isActive) {
             row.slider.requestFocus();
         }
-        final ColorStateList tint = isActive && row.slider.isEnabled() ? mActiveSliderTint
-                : mInactiveSliderTint;
-        if (tint == row.cachedSliderTint) return;
-        row.cachedSliderTint = tint;
+        final ColorStateList tint = isActive && row.slider.isEnabled() ? mActiveTint
+                : mInactiveTint;
+        if (tint == row.cachedTint) return;
         row.slider.setProgressTintList(tint);
         row.slider.setThumbTintList(tint);
+        row.icon.setImageTintList(tint);
+        row.cachedTint = tint;
     }
 
     private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) {
         row.slider.setEnabled(enable);
-        updateVolumeRowSliderTintH(row, row.stream == mActiveStream);
+        updateVolumeRowTintH(row, row.stream == mActiveStream);
         if (row.tracking) {
             return;  // don't update if user is sliding
         }
@@ -1234,7 +1233,7 @@
         private int iconMuteRes;
         private boolean important;
         private boolean defaultStream;
-        private ColorStateList cachedSliderTint;
+        private ColorStateList cachedTint;
         private int iconState;  // from Events
         private ObjectAnimator anim;  // slider progress animation for non-touch-related updates
         private int animTargetProgress;
diff --git a/services/core/java/com/android/server/media/MediaUpdateService.java b/services/core/java/com/android/server/media/MediaUpdateService.java
index f38b353..af06d15 100644
--- a/services/core/java/com/android/server/media/MediaUpdateService.java
+++ b/services/core/java/com/android/server/media/MediaUpdateService.java
@@ -23,11 +23,14 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.media.IMediaExtractorUpdateService;
+import android.os.Build;
 import android.os.IBinder;
 import android.os.Handler;
 import android.os.PatternMatcher;
 import android.os.ServiceManager;
+import android.os.SystemProperties;
 import android.os.UserHandle;
+import android.text.TextUtils;
 import android.util.Log;
 import android.util.Slog;
 import com.android.server.SystemService;
@@ -36,7 +39,8 @@
 public class MediaUpdateService extends SystemService {
     private static final String TAG = "MediaUpdateService";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private static final String MEDIA_UPDATE_PACKAGE_NAME = "com.android.media.update";
+    private static final String MEDIA_UPDATE_PACKAGE_NAME =
+            SystemProperties.get("ro.mediacomponents.package");
     private static final String EXTRACTOR_UPDATE_SERVICE_NAME = "media.extractor.update";
 
     private IMediaExtractorUpdateService mMediaExtractorUpdateService;
@@ -49,7 +53,8 @@
 
     @Override
     public void onStart() {
-        if ("userdebug".equals(android.os.Build.TYPE) || "eng".equals(android.os.Build.TYPE)) {
+        if (("userdebug".equals(android.os.Build.TYPE) || "eng".equals(android.os.Build.TYPE))
+                && !TextUtils.isEmpty(MEDIA_UPDATE_PACKAGE_NAME)) {
             connect();
             registerBroadcastReceiver();
         }
@@ -133,6 +138,12 @@
         } catch (Exception e) {
             Slog.v(TAG, "package '" + MEDIA_UPDATE_PACKAGE_NAME + "' not installed");
         }
+        if (packageInfo != null && Build.VERSION.SDK_INT != packageInfo.targetSdkVersion) {
+            Slog.w(TAG, "This update package is not for this platform version. Ignoring. "
+                    + "platform:" + Build.VERSION.SDK_INT
+                    + " targetSdk:" + packageInfo.targetSdkVersion);
+            pluginsAvailable = false;
+        }
         loadExtractorPlugins(
                 (packageInfo != null && pluginsAvailable) ? packageInfo.sourceDir : "");
     }
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index 4e848f8..e3ff72b 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -286,6 +286,16 @@
     private long mPersistThreshold = 2 * MB_IN_BYTES;
     private long mGlobalAlertBytes;
 
+    private static final long POLL_RATE_LIMIT_MS = 15_000;
+
+    private long mLastStatsSessionPoll;
+
+    /** Map from UID to number of opened sessions */
+    @GuardedBy("mOpenSessionCallsPerUid")
+    private final SparseIntArray mOpenSessionCallsPerUid = new SparseIntArray();
+
+    private final static int DUMP_STATS_SESSION_COUNT = 20;
+
     private static @NonNull File getDefaultSystemDir() {
         return new File(Environment.getDataDirectory(), "system");
     }
@@ -509,10 +519,31 @@
         return openSessionInternal(flags, callingPackage);
     }
 
+    private boolean isRateLimitedForPoll(int callingUid) {
+        if (callingUid == android.os.Process.SYSTEM_UID) {
+            return false;
+        }
+
+        final long lastCallTime;
+        final long now = SystemClock.elapsedRealtime();
+        synchronized (mOpenSessionCallsPerUid) {
+            int calls = mOpenSessionCallsPerUid.get(callingUid, 0);
+            mOpenSessionCallsPerUid.put(callingUid, calls + 1);
+            lastCallTime = mLastStatsSessionPoll;
+            mLastStatsSessionPoll = now;
+        }
+
+        return now - lastCallTime < POLL_RATE_LIMIT_MS;
+    }
+
     private INetworkStatsSession openSessionInternal(final int flags, final String callingPackage) {
         assertBandwidthControlEnabled();
 
-        if ((flags & NetworkStatsManager.FLAG_POLL_ON_OPEN) != 0) {
+        final int callingUid = Binder.getCallingUid();
+        final int usedFlags = isRateLimitedForPoll(callingUid)
+                ? flags & (~NetworkStatsManager.FLAG_POLL_ON_OPEN)
+                : flags;
+        if ((usedFlags & NetworkStatsManager.FLAG_POLL_ON_OPEN) != 0) {
             final long ident = Binder.clearCallingIdentity();
             try {
                 performPoll(FLAG_PERSIST_ALL);
@@ -525,7 +556,7 @@
         // for its lifetime; when caller closes only weak references remain.
 
         return new INetworkStatsSession.Stub() {
-            private final int mCallingUid = Binder.getCallingUid();
+            private final int mCallingUid = callingUid;
             private final String mCallingPackage = callingPackage;
             private final @NetworkStatsAccess.Level int mAccessLevel = checkAccessLevel(
                     callingPackage);
@@ -559,20 +590,20 @@
             @Override
             public NetworkStats getDeviceSummaryForNetwork(
                     NetworkTemplate template, long start, long end) {
-                return internalGetSummaryForNetwork(template, flags, start, end, mAccessLevel,
+                return internalGetSummaryForNetwork(template, usedFlags, start, end, mAccessLevel,
                         mCallingUid);
             }
 
             @Override
             public NetworkStats getSummaryForNetwork(
                     NetworkTemplate template, long start, long end) {
-                return internalGetSummaryForNetwork(template, flags, start, end, mAccessLevel,
+                return internalGetSummaryForNetwork(template, usedFlags, start, end, mAccessLevel,
                         mCallingUid);
             }
 
             @Override
             public NetworkStatsHistory getHistoryForNetwork(NetworkTemplate template, int fields) {
-                return internalGetHistoryForNetwork(template, flags, fields, mAccessLevel,
+                return internalGetHistoryForNetwork(template, usedFlags, fields, mAccessLevel,
                         mCallingUid);
             }
 
@@ -1461,6 +1492,30 @@
             }
             pw.decreaseIndent();
 
+            // Get the top openSession callers
+            final SparseIntArray calls;
+            synchronized (mOpenSessionCallsPerUid) {
+                calls = mOpenSessionCallsPerUid.clone();
+            }
+
+            final int N = calls.size();
+            final long[] values = new long[N];
+            for (int j = 0; j < N; j++) {
+                values[j] = ((long) calls.valueAt(j) << 32) | calls.keyAt(j);
+            }
+            Arrays.sort(values);
+
+            pw.println("Top openSession callers (uid=count):");
+            pw.increaseIndent();
+            final int end = Math.max(0, N - DUMP_STATS_SESSION_COUNT);
+            for (int j = N - 1; j >= end; j--) {
+                final int uid = (int) (values[j] & 0xffffffff);
+                final int count = (int) (values[j] >> 32);
+                pw.print(uid); pw.print("="); pw.println(count);
+            }
+            pw.decreaseIndent();
+            pw.println();
+
             pw.println("Dev stats:");
             pw.increaseIndent();
             mDevRecorder.dumpLocked(pw, fullHistory);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 55f51c2..c6886da 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2394,6 +2394,12 @@
         }
 
         @Override
+        public int getBlockedAppCount(int userId) {
+            checkCallerIsSystem();
+            return mRankingHelper.getBlockedAppCount(userId);
+        }
+
+        @Override
         public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException {
             checkCallerIsSystem();
 
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index c2ec79b..89bd660 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -1011,6 +1011,21 @@
         return blockedCount;
     }
 
+    public int getBlockedAppCount(int userId) {
+        int count = 0;
+        synchronized (mRecords) {
+            final int N = mRecords.size();
+            for (int i = 0; i < N; i++) {
+                final Record r = mRecords.valueAt(i);
+                if (userId == UserHandle.getUserId(r.uid)
+                        && r.importance == IMPORTANCE_NONE) {
+                    count++;
+                }
+            }
+        }
+        return count;
+    }
+
     /**
      * Sets importance.
      */
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java
index 78aa965..bda6b8a 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java
@@ -1733,4 +1733,24 @@
         mHelper.createNotificationChannel(PKG, 1000, update, true, false);
         assertFalse(mHelper.getNotificationChannel(PKG, 1000, "A", false).canBypassDnd());
     }
+
+    @Test
+    public void testGetBlockedAppCount_noApps() {
+        assertEquals(0, mHelper.getBlockedAppCount(0));
+    }
+
+    @Test
+    public void testGetBlockedAppCount_noAppsForUserId() {
+        mHelper.setEnabled(PKG, 100, false);
+        assertEquals(0, mHelper.getBlockedAppCount(9));
+    }
+
+    @Test
+    public void testGetBlockedAppCount_appsForUserId() {
+        mHelper.setEnabled(PKG, 1020, false);
+        mHelper.setEnabled(PKG, 1030, false);
+        mHelper.setEnabled(PKG, 1060, false);
+        mHelper.setEnabled(PKG, 1000, true);
+        assertEquals(3, mHelper.getBlockedAppCount(0));
+    }
 }
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index e244131..024f242 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1687,6 +1687,7 @@
      * Controls if the device should automatically notify the user as they reach
      * their cellular data warning. When set to {@code false} the carrier is
      * expected to have implemented their own notification mechanism.
+     * @hide
      */
     public static final String KEY_DATA_WARNING_NOTIFICATION_BOOL =
             "data_warning_notification_bool";
@@ -1709,6 +1710,7 @@
      * Controls if the device should automatically notify the user as they reach
      * their cellular data limit. When set to {@code false} the carrier is
      * expected to have implemented their own notification mechanism.
+     * @hide
      */
     public static final String KEY_DATA_LIMIT_NOTIFICATION_BOOL =
             "data_limit_notification_bool";
@@ -1717,6 +1719,7 @@
      * Controls if the device should automatically notify the user when rapid
      * cellular data usage is observed. When set to {@code false} the carrier is
      * expected to have implemented their own notification mechanism.
+     * @hide
      */
     public static final String KEY_DATA_RAPID_NOTIFICATION_BOOL =
             "data_rapid_notification_bool";