Merge "Fix issue #29438842: Enter the "am broadcast -a..." into nyc-dev
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index 69b5a17..5bf8076 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -122,6 +122,11 @@
             return;
         }
 
+        if ("whitelist".equals(op)) {
+            doPrintWhitelist();
+            return;
+        }
+
         System.err.println("Unknown command");
         showUsage();
     }
@@ -604,6 +609,20 @@
         }
     }
 
+    private void doPrintWhitelist() {
+        try {
+            final String[] whitelist = mBmgr.getTransportWhitelist();
+            if (whitelist != null) {
+                for (String transport : whitelist) {
+                    System.out.println(transport);
+                }
+            }
+        } catch (RemoteException e) {
+            System.err.println(e.toString());
+            System.err.println(BMGR_NOT_RUNNING_ERR);
+        }
+    }
+
     private String nextArg() {
         if (mNextArg >= mArgs.length) {
             return null;
diff --git a/core/java/android/app/backup/IBackupManager.aidl b/core/java/android/app/backup/IBackupManager.aidl
index 5d4cc6f..a320bbf 100644
--- a/core/java/android/app/backup/IBackupManager.aidl
+++ b/core/java/android/app/backup/IBackupManager.aidl
@@ -218,6 +218,14 @@
     String[] listAllTransports();
 
     /**
+     * Retrieve the list of whitelisted transport components.  Callers do </i>not</i> need
+     * any special permission.
+     *
+     * @return The names of all whitelisted transport components defined by the system.
+     */
+    String[] getTransportWhitelist();
+
+    /**
      * Specify the current backup transport.  Callers must hold the
      * android.permission.BACKUP permission to use this method.
      *
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index f4bf3ea..4acb729 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -2385,6 +2385,13 @@
     public abstract LongCounter getDischargeCoulombCounter();
 
     /**
+     * Returns the estimated real battery capacity, which may be less than the capacity
+     * declared by the PowerProfile.
+     * @return The estimated battery capacity in mAh.
+     */
+    public abstract int getEstimatedBatteryCapacity();
+
+    /**
      * Return the array of discharge step durations.
      */
     public abstract LevelStepTracker getDischargeLevelStepTracker();
@@ -2836,7 +2843,8 @@
                 whichBatteryRealtime / 1000, whichBatteryUptime / 1000,
                 totalRealtime / 1000, totalUptime / 1000,
                 getStartClockTime(),
-                whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000);
+                whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000,
+                getEstimatedBatteryCapacity());
 
         
         // Calculate wakelock times across all uids.
@@ -3348,6 +3356,16 @@
         final SparseArray<? extends Uid> uidStats = getUidStats();
         final int NU = uidStats.size();
 
+        final int estimatedBatteryCapacity = getEstimatedBatteryCapacity();
+        if (estimatedBatteryCapacity > 0) {
+            sb.setLength(0);
+            sb.append(prefix);
+                sb.append("  Estimated battery capacity: ");
+                sb.append(BatteryStatsHelper.makemAh(estimatedBatteryCapacity));
+                sb.append(" mAh");
+            pw.println(sb.toString());
+        }
+
         sb.setLength(0);
         sb.append(prefix);
                 sb.append("  Time on battery: ");
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 2d1e0bd..15eb8de 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -141,17 +141,38 @@
      */
     public static int loadWebViewNativeLibraryFromPackage(String packageName,
                                                           ClassLoader clazzLoader) {
-        int ret = waitForProviderAndSetPackageInfo();
-        if (ret != LIBLOAD_SUCCESS && ret != LIBLOAD_FAILED_WAITING_FOR_RELRO) {
-            return ret;
+        WebViewProviderResponse response = null;
+        try {
+            response = getUpdateService().waitForAndGetProvider();
+        } catch (RemoteException e) {
+            Log.e(LOGTAG, "error waiting for relro creation", e);
+            return LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN;
         }
-        if (!sPackageInfo.packageName.equals(packageName))
+
+
+        if (response.status != LIBLOAD_SUCCESS
+                && response.status != LIBLOAD_FAILED_WAITING_FOR_RELRO) {
+            return response.status;
+        }
+        if (!response.packageInfo.packageName.equals(packageName)) {
             return LIBLOAD_WRONG_PACKAGE_NAME;
+        }
+
+        PackageManager packageManager = AppGlobals.getInitialApplication().getPackageManager();
+        PackageInfo packageInfo;
+        try {
+            packageInfo = packageManager.getPackageInfo(packageName,
+                    PackageManager.GET_META_DATA | PackageManager.MATCH_DEBUG_TRIAGED_MISSING);
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.e(LOGTAG, "Couldn't find package " + packageName);
+            return LIBLOAD_WRONG_PACKAGE_NAME;
+        }
+        sPackageInfo = packageInfo;
 
         int loadNativeRet = loadNativeLibrary(clazzLoader);
         // If we failed waiting for relro we want to return that fact even if we successfully load
         // the relro file.
-        if (loadNativeRet == LIBLOAD_SUCCESS) return ret;
+        if (loadNativeRet == LIBLOAD_SUCCESS) return response.status;
         return loadNativeRet;
     }
 
@@ -288,7 +309,7 @@
                 Context webViewContext = initialApplication.createApplicationContext(
                         newPackageInfo.applicationInfo,
                         Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
-                sPackageInfo = response.packageInfo;
+                sPackageInfo = newPackageInfo;
                 return webViewContext;
             } finally {
                 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
@@ -599,22 +620,6 @@
         }
     }
 
-    private static int waitForProviderAndSetPackageInfo() {
-        WebViewProviderResponse response = null;
-        try {
-            response =
-                getUpdateService().waitForAndGetProvider();
-            if (response.status == LIBLOAD_SUCCESS
-                    || response.status == LIBLOAD_FAILED_WAITING_FOR_RELRO) {
-                sPackageInfo = response.packageInfo;
-            }
-        } catch (RemoteException e) {
-            Log.e(LOGTAG, "error waiting for relro creation", e);
-            return LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN;
-        }
-        return response.status;
-    }
-
     // Assumes that we have waited for relro creation and set sPackageInfo
     private static int loadNativeLibrary(ClassLoader clazzLoader) {
         if (!sAddressSpaceReserved) {
diff --git a/core/java/com/android/internal/app/LocaleStore.java b/core/java/com/android/internal/app/LocaleStore.java
index e3fce51..e782c3c 100644
--- a/core/java/com/android/internal/app/LocaleStore.java
+++ b/core/java/com/android/internal/app/LocaleStore.java
@@ -307,6 +307,9 @@
             localizedLocales.add(li.getLangScriptKey());
         }
 
+        // Serbian in Latin script is only partially localized in N.
+        localizedLocales.remove("sr-Latn");
+
         for (LocaleInfo li : sLocaleCache.values()) {
             li.setTranslated(localizedLocales.contains(li.getLangScriptKey()));
         }
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 07d38d7..f853e04 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -108,7 +108,7 @@
     private static final int MAGIC = 0xBA757475; // 'BATSTATS'
 
     // Current on-disk Parcel version
-    private static final int VERSION = 146 + (USE_OLD_HISTORY ? 1000 : 0);
+    private static final int VERSION = 147 + (USE_OLD_HISTORY ? 1000 : 0);
 
     // Maximum number of items we will record in the history.
     private static final int MAX_HISTORY_ITEMS = 2000;
@@ -547,6 +547,8 @@
     private int mLoadedNumConnectivityChange;
     private int mUnpluggedNumConnectivityChange;
 
+    private int mEstimatedBatteryCapacity = -1;
+
     private final NetworkStats.Entry mTmpNetworkStatsEntry = new NetworkStats.Entry();
 
     private PowerProfile mPowerProfile;
@@ -578,6 +580,11 @@
         return mDischargeCounter;
     }
 
+    @Override
+    public int getEstimatedBatteryCapacity() {
+        return mEstimatedBatteryCapacity;
+    }
+
     public BatteryStatsImpl() {
         this(new SystemClocks());
     }
@@ -7625,6 +7632,11 @@
                         numSpeedSteps);
                 firstCpuOfCluster += mPowerProfile.getNumCoresInCpuCluster(i);
             }
+
+            if (mEstimatedBatteryCapacity == -1) {
+                // Initialize the estimated battery capacity to a known preset one.
+                mEstimatedBatteryCapacity = (int) mPowerProfile.getBatteryCapacity();
+            }
         }
     }
 
@@ -8174,6 +8186,7 @@
         for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
             mScreenBrightnessTimer[i].reset(false);
         }
+        mEstimatedBatteryCapacity = (int) mPowerProfile.getBatteryCapacity();
         mInteractiveTimer.reset(false);
         mPowerSaveModeEnabledTimer.reset(false);
         mLastIdleTimeStart = elapsedRealtimeMillis;
@@ -9158,7 +9171,7 @@
     }
 
     void setOnBatteryLocked(final long mSecRealtime, final long mSecUptime, final boolean onBattery,
-            final int oldStatus, final int level) {
+            final int oldStatus, final int level, final int chargeUAh) {
         boolean doWrite = false;
         Message m = mHandler.obtainMessage(MSG_REPORT_POWER_CHANGE);
         m.arg1 = onBattery ? 1 : 0;
@@ -9212,6 +9225,10 @@
                 }
                 doWrite = true;
                 resetAllStatsLocked();
+                if (chargeUAh > 0) {
+                    // Only use the reported coulomb charge value if it is supported and reported.
+                    mEstimatedBatteryCapacity = (int) ((level / 100.0) * (chargeUAh / 1000));
+                }
                 mDischargeStartLevel = level;
                 reset = true;
                 mDischargeStepTracker.init();
@@ -9379,7 +9396,7 @@
                 mDischargeScreenOffCounter.addCountLocked(chargeDiff);
             }
             mHistoryCur.batteryChargeUAh = chargeUAh;
-            setOnBatteryLocked(elapsedRealtime, uptime, onBattery, oldStatus, level);
+            setOnBatteryLocked(elapsedRealtime, uptime, onBattery, oldStatus, level, chargeUAh);
         } else {
             boolean changed = false;
             if (mHistoryCur.batteryLevel != level) {
@@ -10093,6 +10110,7 @@
         mDischargePlugLevel = in.readInt();
         mDischargeCurrentLevel = in.readInt();
         mCurrentBatteryLevel = in.readInt();
+        mEstimatedBatteryCapacity = in.readInt();
         mLowDischargeAmountSinceCharge = in.readInt();
         mHighDischargeAmountSinceCharge = in.readInt();
         mDischargeAmountScreenOnSinceCharge = in.readInt();
@@ -10445,6 +10463,7 @@
         out.writeInt(mDischargePlugLevel);
         out.writeInt(mDischargeCurrentLevel);
         out.writeInt(mCurrentBatteryLevel);
+        out.writeInt(mEstimatedBatteryCapacity);
         out.writeInt(getLowDischargeAmountSinceCharge());
         out.writeInt(getHighDischargeAmountSinceCharge());
         out.writeInt(getDischargeAmountScreenOnSinceCharge());
@@ -10809,6 +10828,7 @@
         mRealtime = in.readLong();
         mRealtimeStart = in.readLong();
         mOnBattery = in.readInt() != 0;
+        mEstimatedBatteryCapacity = in.readInt();
         mOnBatteryInternal = false; // we are no longer really running.
         mOnBatteryTimeBase.readFromParcel(in);
         mOnBatteryScreenOffTimeBase.readFromParcel(in);
@@ -10992,6 +11012,7 @@
         out.writeLong(mRealtime);
         out.writeLong(mRealtimeStart);
         out.writeInt(mOnBattery ? 1 : 0);
+        out.writeInt(mEstimatedBatteryCapacity);
         mOnBatteryTimeBase.writeToParcel(out, uSecUptime, uSecRealtime);
         mOnBatteryScreenOffTimeBase.writeToParcel(out, uSecUptime, uSecRealtime);
 
diff --git a/docs/html/guide/topics/renderscript/compute.jd b/docs/html/guide/topics/renderscript/compute.jd
index 564215e..fc795ff 100755
--- a/docs/html/guide/topics/renderscript/compute.jd
+++ b/docs/html/guide/topics/renderscript/compute.jd
@@ -21,7 +21,7 @@
     <h2>Related Samples</h2>
 
     <ol>
-      <li><a href="{@docRoot}resources/samples/RenderScript/HelloCompute/index.html">Hello
+      <li><a class="external-link"href="https://github.com/android/platform_development/tree/master/samples/RenderScript/HelloCompute">Hello
       Compute</a></li>
     </ol>
   </div>
diff --git a/docs/html/training/articles/user-data-ids.jd b/docs/html/training/articles/user-data-ids.jd
index 5a4648b..9102166 100644
--- a/docs/html/training/articles/user-data-ids.jd
+++ b/docs/html/training/articles/user-data-ids.jd
@@ -189,15 +189,15 @@
 
 <div style="padding:.5em 2em;">
 <div style="border-left:4px solid #999;padding:0 1em;font-style:italic;">
-<p>...upon reset, a new advertising
+<p>...if reset, a new advertising
   identifier must not be connected to a previous advertising identifier or data
   derived from a previous advertising identifier without the explicit consent
-  of the user</span></p>
+  of the user.</span></p>
 </div>
 </div>
 
 <p>
-  <em><strong>Always respect the associated Interest Based Advertising
+  <em><strong>Always respect the associated Personalized Ads
   flag</strong></em>. Advertising IDs are configurable in that users can limit
   the amount of tracking associated with the ID. Always use the <code><a href=
   "https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info.html#isLimitAdTrackingEnabled()">
@@ -210,10 +210,10 @@
 
 <div style="padding:.5em 2em;">
 <div style="border-left:4px solid #999;padding:0 1em;font-style:italic;">
-<p>...you must abide by a user’s ‘opt out of
-  interest-based advertising’ setting. If a user has enabled this setting, you
+<p>...you must abide by a user’s ‘Opt out of interest-based advertising’ or 'Opt
+  out of Ads Personalization' setting. If a user has enabled this setting, you
   may not use the advertising identifier for creating user profiles for
-  advertising purposes or for targeting users with interest-based advertising.
+  advertising purposes or for targeting users with personalized advertising.
   Allowed activities include contextual advertising, frequency capping,
   conversion tracking, reporting and security and fraud detection.</span></p>
 </div>
@@ -286,7 +286,8 @@
   <code>account_id</code> column in both tables, which would be a violation of
   the <a href=
   "https://play.google.com/about/developer-content-policy.html">Google Play
-  Developer Content Policy</a>.
+  Developer Content Policy</a>, if you did not get explicit permission from
+  your users.
 </p>
 
 <p>
diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
index 9d4b50c..1922773 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
@@ -215,9 +215,12 @@
         includeState(state);
 
         // Advanced roots are shown by default without menu option if forced by config or intent.
-        state.showAdvanced = Shared.shouldShowDeviceRoot(this, intent);
+        boolean forceAdvanced = Shared.shouldShowDeviceRoot(this, intent);
+        boolean chosenAdvanced = LocalPreferences.getShowDeviceRoot(this, state.action);
+        state.showAdvanced = forceAdvanced || chosenAdvanced;
+
         // Menu option is shown for whitelisted intents if advanced roots are not shown by default.
-        state.showAdvancedOption = !state.showAdvanced && (
+        state.showAdvancedOption = !forceAdvanced && (
                 Shared.shouldShowFancyFeatures(this)
                 || state.action == ACTION_OPEN
                 || state.action == ACTION_CREATE
@@ -483,6 +486,7 @@
         Metrics.logUserAction(this,
                 display ? Metrics.USER_ACTION_SHOW_ADVANCED : Metrics.USER_ACTION_HIDE_ADVANCED);
 
+        LocalPreferences.setShowDeviceRoot(this, mState.action, display);
         mState.showAdvanced = display;
         RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
         invalidateOptionsMenu();
diff --git a/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java b/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
index 2315664..d2e9885 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
@@ -18,9 +18,6 @@
 
 import static com.android.documentsui.State.MODE_UNKNOWN;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
 import android.annotation.IntDef;
 import android.annotation.Nullable;
 import android.content.Context;
@@ -28,11 +25,16 @@
 import android.os.UserHandle;
 import android.preference.PreferenceManager;
 
+import com.android.documentsui.State.ActionType;
 import com.android.documentsui.State.ViewMode;
 import com.android.documentsui.model.RootInfo;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 public class LocalPreferences {
     private static final String KEY_FILE_SIZE = "fileSize";
+    private static final String INCLUDE_DEVICE_ROOT = "includeDeviceRoot-";
     private static final String ROOT_VIEW_MODE_PREFIX = "rootViewMode-";
 
     public static boolean getDisplayFileSize(Context context) {
@@ -48,9 +50,17 @@
         getPrefs(context).edit().putBoolean(KEY_FILE_SIZE, display).apply();
     }
 
+    public static boolean getShowDeviceRoot(Context context, @ActionType int action) {
+        return getPrefs(context).getBoolean(INCLUDE_DEVICE_ROOT + action, false);
+    }
+
+    public static void setShowDeviceRoot(
+            Context context, @ActionType int action, boolean display) {
+        getPrefs(context).edit().putBoolean(INCLUDE_DEVICE_ROOT + action, display).apply();
+    }
+
     public static void setViewMode(Context context, RootInfo root, @ViewMode int viewMode) {
         assert(viewMode != MODE_UNKNOWN);
-
         getPrefs(context).edit().putInt(createKey(root), viewMode).apply();
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUI.java b/packages/SystemUI/src/com/android/systemui/SystemUI.java
index 85befff..f30baee 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUI.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUI.java
@@ -16,8 +16,10 @@
 
 package com.android.systemui;
 
+import android.app.Notification;
 import android.content.Context;
 import android.content.res.Configuration;
+import android.os.Bundle;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -48,4 +50,12 @@
             mComponents.put(interfaceType, component);
         }
     }
+
+    public static void overrideNotificationAppName(Context context, Notification.Builder n) {
+        final Bundle extras = new Bundle();
+        extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
+                context.getString(com.android.internal.R.string.android_system_label));
+
+        n.addExtras(extras);
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index ea1c9bf..b831235 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -38,6 +38,7 @@
 import android.util.Slog;
 
 import com.android.systemui.R;
+import com.android.systemui.SystemUI;
 import com.android.systemui.statusbar.phone.PhoneStatusBar;
 import com.android.systemui.statusbar.phone.SystemUIDialog;
 
@@ -143,6 +144,7 @@
                 .setVisibility(Notification.VISIBILITY_PUBLIC)
                 .setColor(mContext.getColor(
                         com.android.internal.R.color.system_notification_accent_color));
+        SystemUI.overrideNotificationAppName(mContext, nb);
         final Notification n = nb.build();
         mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
     }
@@ -173,8 +175,8 @@
             attachLowBatterySound(nb);
             mPlaySound = false;
         }
-        final Notification n = nb.build();
-        mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
+        SystemUI.overrideNotificationAppName(mContext, nb);
+        mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, nb.build(), UserHandle.ALL);
     }
 
     private PendingIntent pendingActivity(Intent intent) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 8a7a7fb..27b079a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -634,6 +634,18 @@
         }
     }
 
+    public static class AirplaneBooleanState extends BooleanState {
+        public boolean isAirplaneMode;
+
+        @Override
+        public boolean copyTo(State other) {
+            final AirplaneBooleanState o = (AirplaneBooleanState) other;
+            final boolean changed = super.copyTo(other) || o.isAirplaneMode != isAirplaneMode;
+            o.isAirplaneMode = isAirplaneMode;
+            return changed;
+        }
+    }
+
     public static final class SignalState extends BooleanState {
         public boolean connected;
         public boolean activityIn;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index 1c134c1..d3434e5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -36,15 +36,16 @@
 import com.android.systemui.statusbar.policy.HotspotController;
 
 /** Quick settings tile: Hotspot **/
-public class HotspotTile extends QSTile<QSTile.BooleanState> {
+public class HotspotTile extends QSTile<QSTile.AirplaneBooleanState> {
     private final AnimationIcon mEnable =
             new AnimationIcon(R.drawable.ic_hotspot_enable_animation,
                     R.drawable.ic_hotspot_disable);
     private final AnimationIcon mDisable =
             new AnimationIcon(R.drawable.ic_hotspot_disable_animation,
                     R.drawable.ic_hotspot_enable);
-    private final Icon mUnavailable =
-            ResourceIcon.get(R.drawable.ic_hotspot_unavailable);
+    private final Icon mDisableNoAnimation = ResourceIcon.get(R.drawable.ic_hotspot_enable);
+    private final Icon mUnavailable = ResourceIcon.get(R.drawable.ic_hotspot_unavailable);
+
     private final HotspotController mController;
     private final Callback mCallback = new Callback();
     private final GlobalSetting mAirplaneMode;
@@ -72,8 +73,8 @@
     }
 
     @Override
-    public BooleanState newTileState() {
-        return new BooleanState();
+    public AirplaneBooleanState newTileState() {
+        return new AirplaneBooleanState();
     }
 
     @Override
@@ -84,10 +85,8 @@
             mController.addCallback(mCallback);
             final IntentFilter filter = new IntentFilter();
             filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
-            mContext.registerReceiver(mReceiver, filter);
         } else {
             mController.removeCallback(mCallback);
-            mContext.unregisterReceiver(mReceiver);
         }
         mAirplaneMode.setListening(listening);
     }
@@ -113,7 +112,7 @@
     }
 
     @Override
-    protected void handleUpdateState(BooleanState state, Object arg) {
+    protected void handleUpdateState(AirplaneBooleanState state, Object arg) {
         state.label = mContext.getString(R.string.quick_settings_hotspot_label);
 
         checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING);
@@ -123,12 +122,16 @@
             state.value = mController.isHotspotEnabled();
         }
         state.icon = state.value ? mEnable : mDisable;
-        if (mAirplaneMode.getValue() != 0) {
+        boolean wasAirplane = state.isAirplaneMode;
+        state.isAirplaneMode = mAirplaneMode.getValue() != 0;
+        if (state.isAirplaneMode) {
             final int disabledColor = mHost.getContext().getColor(R.color.qs_tile_tint_unavailable);
             state.label = new SpannableStringBuilder().append(state.label,
                     new ForegroundColorSpan(disabledColor),
                     SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
             state.icon = mUnavailable;
+        } else if (wasAirplane) {
+            state.icon = mDisableNoAnimation;
         }
         state.minimalAccessibilityClassName = state.expandedAccessibilityClassName
                 = Switch.class.getName();
@@ -155,13 +158,4 @@
             refreshState(enabled);
         }
     };
-
-    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
-                refreshState();
-            }
-        }
-    };
 }
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index e6cbbea..d789477 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -60,6 +60,7 @@
 import android.widget.ImageView;
 
 import com.android.systemui.R;
+import com.android.systemui.SystemUI;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -165,11 +166,6 @@
         c.drawColor(overlayColor);
         c.setBitmap(null);
 
-        // swap "System UI" out for "Android System"
-        final Bundle extras = new Bundle();
-        extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
-                context.getString(com.android.internal.R.string.android_system_label));
-
         // Show the intermediate notification
         mTickerAddSpace = !mTickerAddSpace;
         mNotificationManager = nManager;
@@ -187,9 +183,9 @@
                 .setCategory(Notification.CATEGORY_PROGRESS)
                 .setWhen(now)
                 .setShowWhen(true)
-                .addExtras(extras)
                 .setColor(r.getColor(
                         com.android.internal.R.color.system_notification_accent_color));
+        SystemUI.overrideNotificationAppName(context, mPublicNotificationBuilder);
 
         mNotificationBuilder = new Notification.Builder(context)
             .setTicker(r.getString(R.string.screenshot_saving_ticker)
@@ -199,11 +195,11 @@
             .setSmallIcon(R.drawable.stat_notify_image)
             .setWhen(now)
             .setShowWhen(true)
-            .addExtras(extras)
             .setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color))
             .setStyle(mNotificationStyle)
             .setPublicVersion(mPublicNotificationBuilder.build());
         mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
+        SystemUI.overrideNotificationAppName(context, mNotificationBuilder);
 
         mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
 
@@ -864,6 +860,7 @@
             .setAutoCancel(true)
             .setColor(context.getColor(
                         com.android.internal.R.color.system_notification_accent_color));
+        SystemUI.overrideNotificationAppName(context, b);
 
         Notification n = new Notification.BigTextStyle(b)
                 .bigText(errorMsg)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 9e0812e..7bc4100 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -844,7 +844,6 @@
                     new Intent(BANNER_ACTION_SETUP).setPackage(packageName),
                     PendingIntent.FLAG_CANCEL_CURRENT);
 
-            final Resources res = mContext.getResources();
             final int colorRes = com.android.internal.R.color.system_notification_accent_color;
             Notification.Builder note = new Notification.Builder(mContext)
                     .setSmallIcon(R.drawable.ic_android)
@@ -860,6 +859,7 @@
                     .addAction(R.drawable.ic_settings,
                             mContext.getString(R.string.hidden_notifications_setup),
                             setupIntent);
+            overrideNotificationAppName(mContext, note);
 
             NotificationManager noMan =
                     (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index e1d4c8a..f09eae8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -185,6 +185,7 @@
                 }
     };
     private OnClickListener mOnClickListener;
+    private boolean mHeadsupDisappearRunning;
     private View mChildAfterViewWhenDismissed;
     private View mGroupParentWhenDismissed;
     private boolean mRefocusOnDismiss;
@@ -759,15 +760,17 @@
         mRemoved = true;
 
         mPrivateLayout.setRemoved();
-        if (mChildrenContainer != null) {
-            mChildrenContainer.setRemoved();
-        }
     }
 
     public NotificationChildrenContainer getChildrenContainer() {
         return mChildrenContainer;
     }
 
+    public void setHeadsupDisappearRunning(boolean running) {
+        mHeadsupDisappearRunning = running;
+        mPrivateLayout.setHeadsupDisappearRunning(running);
+    }
+
     public View getChildAfterViewWhenDismissed() {
         return mChildAfterViewWhenDismissed;
     }
@@ -1173,8 +1176,8 @@
             return getMinHeight();
         } else if (mIsSummaryWithChildren && !mOnKeyguard) {
             return mChildrenContainer.getIntrinsicHeight();
-        } else if (mIsHeadsUp) {
-            if (isPinned()) {
+        } else if (mIsHeadsUp || mHeadsupDisappearRunning) {
+            if (isPinned() || mHeadsupDisappearRunning) {
                 return getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
             } else if (isExpanded()) {
                 return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
@@ -1300,6 +1303,10 @@
         if (!animated) {
             mPublicLayout.animate().cancel();
             mPrivateLayout.animate().cancel();
+            if (mChildrenContainer != null) {
+                mChildrenContainer.animate().cancel();
+                mChildrenContainer.setAlpha(1f);
+            }
             mPublicLayout.setAlpha(1f);
             mPrivateLayout.setAlpha(1f);
             mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 30ac9ca..9fd09d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -119,6 +119,7 @@
 
     private int mContentHeightAtAnimationStart = UNDEFINED;
     private boolean mFocusOnVisibilityChange;
+    private boolean mHeadsupDisappearRunning;
 
 
     public NotificationContentView(Context context, AttributeSet attrs) {
@@ -446,7 +447,8 @@
             boolean transitioningBetweenHunAndExpanded =
                     isTransitioningFromTo(VISIBLE_TYPE_HEADSUP, VISIBLE_TYPE_EXPANDED) ||
                     isTransitioningFromTo(VISIBLE_TYPE_EXPANDED, VISIBLE_TYPE_HEADSUP);
-            boolean pinned = !isVisibleOrTransitioning(VISIBLE_TYPE_CONTRACTED) && mIsHeadsUp;
+            boolean pinned = !isVisibleOrTransitioning(VISIBLE_TYPE_CONTRACTED)
+                    && (mIsHeadsUp || mHeadsupDisappearRunning);
             if (transitioningBetweenHunAndExpanded || pinned) {
                 return Math.min(mHeadsUpChild.getHeight(), mExpandedChild.getHeight());
             }
@@ -830,7 +832,7 @@
             return VISIBLE_TYPE_SINGLELINE;
         }
 
-        if (mIsHeadsUp && mHeadsUpChild != null) {
+        if ((mIsHeadsUp || mHeadsupDisappearRunning) && mHeadsUpChild != null) {
             if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
                 return VISIBLE_TYPE_HEADSUP;
             } else {
@@ -1153,6 +1155,11 @@
         }
     }
 
+    public void setHeadsupDisappearRunning(boolean headsupDisappearRunning) {
+        mHeadsupDisappearRunning = headsupDisappearRunning;
+        selectLayout(false /* animate */, true /* force */);
+    }
+
     public void setFocusOnVisibilityChange() {
         mFocusOnVisibilityChange = true;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index 9ecff18d..204ab7e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -213,18 +213,18 @@
         return isGroupSuppressed(getGroupKey(sbn)) && sbn.getNotification().isGroupSummary();
     }
 
-    public boolean isOnlyChildInSuppressedGroup(StatusBarNotification sbn) {
-        return isGroupSuppressed(sbn.getGroupKey())
-                && isOnlyChild(sbn);
-    }
-
     private boolean isOnlyChild(StatusBarNotification sbn) {
         return !sbn.getNotification().isGroupSummary()
                 && getTotalNumberOfChildren(sbn) == 1;
     }
 
     public boolean isOnlyChildInGroup(StatusBarNotification sbn) {
-        return isOnlyChild(sbn) && getLogicalGroupSummary(sbn) != null;
+        if (!isOnlyChild(sbn)) {
+            return false;
+        }
+        ExpandableNotificationRow logicalGroupSummary = getLogicalGroupSummary(sbn);
+        return logicalGroupSummary != null
+                && !logicalGroupSummary.getStatusBarNotification().equals(sbn);
     }
 
     private int getTotalNumberOfChildren(StatusBarNotification sbn) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index 415b7a1..89d2712 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -51,6 +51,7 @@
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.systemui.GuestResumeSessionReceiver;
 import com.android.systemui.R;
+import com.android.systemui.SystemUI;
 import com.android.systemui.SystemUISecondaryUserService;
 import com.android.systemui.qs.QSTile;
 import com.android.systemui.qs.tiles.UserDetailView;
@@ -523,7 +524,7 @@
         private void showLogoutNotification(int userId) {
             PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
                     0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
-            Notification notification = new Notification.Builder(mContext)
+            Notification.Builder builder = new Notification.Builder(mContext)
                     .setVisibility(Notification.VISIBILITY_SECRET)
                     .setPriority(Notification.PRIORITY_MIN)
                     .setSmallIcon(R.drawable.ic_person)
@@ -534,10 +535,10 @@
                     .setShowWhen(false)
                     .addAction(R.drawable.ic_delete,
                             mContext.getString(R.string.user_logout_notification_action),
-                            logoutPI)
-                    .build();
+                            logoutPI);
+            SystemUI.overrideNotificationAppName(mContext, builder);
             NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, ID_LOGOUT_USER,
-                    notification, new UserHandle(userId));
+                    builder.build(), new UserHandle(userId));
         }
     };
 
@@ -547,7 +548,7 @@
         PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
                 0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
 
-        Notification notification = new Notification.Builder(mContext)
+        Notification.Builder builder = new Notification.Builder(mContext)
                 .setVisibility(Notification.VISIBILITY_SECRET)
                 .setPriority(Notification.PRIORITY_MIN)
                 .setSmallIcon(R.drawable.ic_person)
@@ -557,10 +558,10 @@
                 .setShowWhen(false)
                 .addAction(R.drawable.ic_delete,
                         mContext.getString(R.string.guest_notification_remove_action),
-                        removeGuestPI)
-                .build();
+                        removeGuestPI);
+        SystemUI.overrideNotificationAppName(mContext, builder);
         NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
-                notification, new UserHandle(guestUserId));
+                builder.build(), new UserHandle(guestUserId));
     }
 
     private final Runnable mUnpauseRefreshUsers = new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index ba191cd..3c9373b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -856,14 +856,6 @@
                 mNotificationParent.getNotificationColor());
     }
 
-    public void setRemoved() {
-        int childCount = mChildren.size();
-        for (int i = 0; i < childCount; i++) {
-            ExpandableNotificationRow child = mChildren.get(i);
-            child.setRemoved();
-        }
-    }
-
     public int getPositionInLinearLayout(View childInGroup) {
         int position = mNotificationHeaderMargin + mNotificatonTopPadding;
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 71ef1ea..7de3879 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -3689,6 +3689,9 @@
         if (mAnimationsEnabled) {
             mHeadsUpChangeAnimations.add(new Pair<>(row, isHeadsUp));
             mNeedsAnimation = true;
+            if (!mIsExpanded && !isHeadsUp) {
+                row.setHeadsupDisappearRunning(true);
+            }
             requestChildrenUpdate();
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
index 7ac0d80..5bebbca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
@@ -733,6 +733,7 @@
             animator.setStartDelay(delay);
         }
         animator.addListener(getGlobalAnimationFinishedListener());
+        final boolean isHeadsUpDisappear = mHeadsUpDisappearChildren.contains(child);
         // remove the tag when the animation is finished
         animator.addListener(new AnimatorListenerAdapter() {
             @Override
@@ -741,6 +742,9 @@
                 child.setTag(TAG_ANIMATOR_TRANSLATION_Y, null);
                 child.setTag(TAG_START_TRANSLATION_Y, null);
                 child.setTag(TAG_END_TRANSLATION_Y, null);
+                if (isHeadsUpDisappear) {
+                    ((ExpandableNotificationRow) child).setHeadsupDisappearRunning(false);
+                }
             }
         });
         startAnimator(animator);
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 36dd727..97d5e10 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -198,7 +198,7 @@
                         rec.getNickname());
                 final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
 
-                final Notification notif = new Notification.Builder(mContext)
+                Notification.Builder builder = new Notification.Builder(mContext)
                         .setSmallIcon(R.drawable.ic_sd_card_48dp)
                         .setColor(mContext.getColor(R.color.system_notification_accent_color))
                         .setContentTitle(title)
@@ -208,10 +208,11 @@
                         .setVisibility(Notification.VISIBILITY_PUBLIC)
                         .setLocalOnly(true)
                         .setCategory(Notification.CATEGORY_SYSTEM)
-                        .setDeleteIntent(buildSnoozeIntent(fsUuid))
-                        .build();
+                        .setDeleteIntent(buildSnoozeIntent(fsUuid));
+                SystemUI.overrideNotificationAppName(mContext, builder);
 
-                mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, notif, UserHandle.ALL);
+                mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder
+                        .build(), UserHandle.ALL);
             }
         }
     }
@@ -224,7 +225,7 @@
             final CharSequence text = mContext.getString(
                     R.string.ext_media_unsupported_notification_message, disk.getDescription());
 
-            final Notification notif = new Notification.Builder(mContext)
+            Notification.Builder builder = new Notification.Builder(mContext)
                     .setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
                     .setColor(mContext.getColor(R.color.system_notification_accent_color))
                     .setContentTitle(title)
@@ -233,10 +234,11 @@
                     .setStyle(new Notification.BigTextStyle().bigText(text))
                     .setVisibility(Notification.VISIBILITY_PUBLIC)
                     .setLocalOnly(true)
-                    .setCategory(Notification.CATEGORY_ERROR)
-                    .build();
+                    .setCategory(Notification.CATEGORY_ERROR);
+            SystemUI.overrideNotificationAppName(mContext, builder);
 
-            mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, notif, UserHandle.ALL);
+            mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, builder.build(),
+                    UserHandle.ALL);
 
         } else {
             // Yay, we have volumes!
@@ -471,7 +473,7 @@
             intent = buildWizardMigratePendingIntent(move);
         }
 
-        final Notification notif = new Notification.Builder(mContext)
+        Notification.Builder builder = new Notification.Builder(mContext)
                 .setSmallIcon(R.drawable.ic_sd_card_48dp)
                 .setColor(mContext.getColor(R.color.system_notification_accent_color))
                 .setContentTitle(title)
@@ -483,10 +485,11 @@
                 .setCategory(Notification.CATEGORY_PROGRESS)
                 .setPriority(Notification.PRIORITY_LOW)
                 .setProgress(100, status, false)
-                .setOngoing(true)
-                .build();
+                .setOngoing(true);
+        SystemUI.overrideNotificationAppName(mContext, builder);
 
-        mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
+        mNotificationManager.notifyAsUser(move.packageName, MOVE_ID,
+                builder.build(), UserHandle.ALL);
     }
 
     private void onMoveFinished(MoveInfo move, int status) {
@@ -520,7 +523,7 @@
             intent = null;
         }
 
-        final Notification notif = new Notification.Builder(mContext)
+        Notification.Builder builder = new Notification.Builder(mContext)
                 .setSmallIcon(R.drawable.ic_sd_card_48dp)
                 .setColor(mContext.getColor(R.color.system_notification_accent_color))
                 .setContentTitle(title)
@@ -531,10 +534,11 @@
                 .setLocalOnly(true)
                 .setCategory(Notification.CATEGORY_SYSTEM)
                 .setPriority(Notification.PRIORITY_LOW)
-                .setAutoCancel(true)
-                .build();
+                .setAutoCancel(true);
+        SystemUI.overrideNotificationAppName(mContext, builder);
 
-        mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
+        mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(),
+                UserHandle.ALL);
     }
 
     private int getSmallIcon(DiskInfo disk, int state) {
@@ -555,7 +559,7 @@
 
     private Notification.Builder buildNotificationBuilder(VolumeInfo vol, CharSequence title,
             CharSequence text) {
-        return new Notification.Builder(mContext)
+        Notification.Builder builder = new Notification.Builder(mContext)
                 .setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
                 .setColor(mContext.getColor(R.color.system_notification_accent_color))
                 .setContentTitle(title)
@@ -563,6 +567,8 @@
                 .setStyle(new Notification.BigTextStyle().bigText(text))
                 .setVisibility(Notification.VISIBILITY_PUBLIC)
                 .setLocalOnly(true);
+        overrideNotificationAppName(mContext, builder);
+        return builder;
     }
 
     private PendingIntent buildInitPendingIntent(DiskInfo disk) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 2688813..c820302 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -228,22 +228,23 @@
             }
             final Intent intent =  new Intent(Receiver.DISABLE)
                     .putExtra(Receiver.EXTRA_COMPONENT, component);
+            Notification.Builder builder = new Notification.Builder(mContext)
+                    .setSmallIcon(R.drawable.ic_volume_media)
+                    .setWhen(0)
+                    .setShowWhen(false)
+                    .setOngoing(true)
+                    .setContentTitle(mContext.getString(
+                            R.string.volumeui_notification_title, getAppLabel(component)))
+                    .setContentText(mContext.getString(R.string.volumeui_notification_text))
+                    .setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
+                            PendingIntent.FLAG_UPDATE_CURRENT))
+                    .setPriority(Notification.PRIORITY_MIN)
+                    .setVisibility(Notification.VISIBILITY_PUBLIC)
+                    .setColor(mContext.getColor(
+                            com.android.internal.R.color.system_notification_accent_color));
+            overrideNotificationAppName(mContext, builder);
             mNotificationManager.notify(R.id.notification_volumeui,
-                    new Notification.Builder(mContext)
-                            .setSmallIcon(R.drawable.ic_volume_media)
-                            .setWhen(0)
-                            .setShowWhen(false)
-                            .setOngoing(true)
-                            .setContentTitle(mContext.getString(
-                                    R.string.volumeui_notification_title, getAppLabel(component)))
-                            .setContentText(mContext.getString(R.string.volumeui_notification_text))
-                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
-                                    PendingIntent.FLAG_UPDATE_CURRENT))
-                            .setPriority(Notification.PRIORITY_MIN)
-                            .setVisibility(Notification.VISIBILITY_PUBLIC)
-                            .setColor(mContext.getColor(
-                                    com.android.internal.R.color.system_notification_accent_color))
-                            .build());
+                    builder.build());
         }
     }
 }
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 930c151b..eea771d 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -9598,6 +9598,15 @@
         return list;
     }
 
+    public String[] getTransportWhitelist() {
+        // No permission check, intentionally.
+        String[] whitelist = new String[mTransportWhitelist.size()];
+        for (int i = mTransportWhitelist.size() - 1; i >= 0; i--) {
+            whitelist[i] = mTransportWhitelist.valueAt(i).flattenToShortString();
+        }
+        return whitelist;
+    }
+
     // Select which transport to use for the next backup operation.
     public String selectBackupTransport(String transport) {
         mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
diff --git a/services/backup/java/com/android/server/backup/Trampoline.java b/services/backup/java/com/android/server/backup/Trampoline.java
index e745263..312b878 100644
--- a/services/backup/java/com/android/server/backup/Trampoline.java
+++ b/services/backup/java/com/android/server/backup/Trampoline.java
@@ -275,6 +275,12 @@
     }
 
     @Override
+    public String[] getTransportWhitelist() {
+        BackupManagerService svc = mService;
+        return (svc != null) ? svc.getTransportWhitelist() : null;
+    }
+
+    @Override
     public String selectBackupTransport(String transport) throws RemoteException {
         BackupManagerService svc = mService;
         return (svc != null) ? svc.selectBackupTransport(transport) : null;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 3a8ef08..159a1bf 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -18793,7 +18793,7 @@
                 starting = mainStack.topRunningActivityLocked();
             }
 
-            if (starting != null && starting.state != ActivityState.STOPPED) {
+            if (starting != null) {
                 kept = mainStack.ensureActivityConfigurationLocked(starting, changes, false);
                 // And we need to make sure at this point that all other activities
                 // are made visible with the correct configuration.
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 37d7c33..6510cb4 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -444,10 +444,17 @@
             return;
         }
         try {
+            // Make sure fontScale is always equal to global. For fullscreen apps, config is
+            // the shared EMPTY config, which has default fontScale of 1.0. We don't want it
+            // to be applied as an override config.
+            Configuration overrideConfig = new Configuration(config);
+            overrideConfig.fontScale = service.mConfiguration.fontScale;
+
             if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " +
-                    "reportToActivity=" + reportToActivity + " and config: " + config);
+                    "reportToActivity=" + reportToActivity + " and config: " + overrideConfig);
+
             app.thread.scheduleActivityConfigurationChanged(
-                    appToken, new Configuration(config), reportToActivity);
+                    appToken, overrideConfig, reportToActivity);
         } catch (RemoteException e) {
             // If process died, whatever.
         }
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 6af7a5d..c5eacd6 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1820,8 +1820,7 @@
             boolean stackVisibleBehind, ActivityRecord visibleBehind,
             boolean behindFullscreenActivity) {
 
-        if (!okToShowLocked(r)
-                || (mService.isSleepingOrShuttingDownLocked() && r.voiceSession == null)) {
+        if (!okToShowLocked(r)) {
             return false;
         }
 
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c8307d8..2a85694 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -1214,7 +1214,9 @@
                     StringBuffer sb = new StringBuffer();
 
                     String firstLine = readLine(in, sb);
-                    if (firstLine.equals(USAGE_FILE_MAGIC_VERSION_1)) {
+                    if (firstLine == null) {
+                        // Empty file. Do nothing.
+                    } else if (USAGE_FILE_MAGIC_VERSION_1.equals(firstLine)) {
                         readVersion1LP(in, sb);
                     } else {
                         readVersion0LP(in, sb, firstLine);