Merge "Qualify the uid with the userId when granting permissions" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 399c1df..af95867 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -14722,6 +14722,7 @@
     field public static final int TYPE_FM_TUNER = 16; // 0x10
     field public static final int TYPE_HDMI = 9; // 0x9
     field public static final int TYPE_HDMI_ARC = 10; // 0xa
+    field public static final int TYPE_IP = 20; // 0x14
     field public static final int TYPE_LINE_ANALOG = 5; // 0x5
     field public static final int TYPE_LINE_DIGITAL = 6; // 0x6
     field public static final int TYPE_TELEPHONY = 18; // 0x12
diff --git a/api/system-current.txt b/api/system-current.txt
index e64567c..9fce166 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -15961,6 +15961,7 @@
     field public static final int TYPE_FM_TUNER = 16; // 0x10
     field public static final int TYPE_HDMI = 9; // 0x9
     field public static final int TYPE_HDMI_ARC = 10; // 0xa
+    field public static final int TYPE_IP = 20; // 0x14
     field public static final int TYPE_LINE_ANALOG = 5; // 0x5
     field public static final int TYPE_LINE_DIGITAL = 6; // 0x6
     field public static final int TYPE_TELEPHONY = 18; // 0x12
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 6c74a9f..547cce4 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -738,7 +738,9 @@
     /**
      * <p>List of edge enhancement modes for {@link CaptureRequest#EDGE_MODE android.edge.mode} that are supported by this camera
      * device.</p>
-     * <p>Full-capability camera devices must always support OFF; all devices will list FAST.</p>
+     * <p>Full-capability camera devices must always support OFF; camera devices that support
+     * YUV_REPROCESSING or PRIVATE_REPROCESSING will list ZERO_SHUTTER_LAG; all devices will
+     * list FAST.</p>
      * <p><b>Range of valid values:</b><br>
      * Any value listed in {@link CaptureRequest#EDGE_MODE android.edge.mode}</p>
      * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
@@ -1176,6 +1178,8 @@
      * <p>List of noise reduction modes for {@link CaptureRequest#NOISE_REDUCTION_MODE android.noiseReduction.mode} that are supported
      * by this camera device.</p>
      * <p>Full-capability camera devices will always support OFF and FAST.</p>
+     * <p>Camera devices that support YUV_REPROCESSING or PRIVATE_REPROCESSING will support
+     * ZERO_SHUTTER_LAG.</p>
      * <p>Legacy-capability camera devices will only support FAST mode.</p>
      * <p><b>Range of valid values:</b><br>
      * Any value listed in {@link CaptureRequest#NOISE_REDUCTION_MODE android.noiseReduction.mode}</p>
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index f7c6274..0aa6447 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -2024,7 +2024,8 @@
      * reasonable preview quality.</p>
      * <p>This mode is guaranteed to be supported by devices that support either the
      * YUV_REPROCESSING or PRIVATE_REPROCESSING capabilities
-     * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} lists either of those capabilities).</p>
+     * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} lists either of those capabilities) and it will
+     * be the default mode for CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG template.</p>
      *
      * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
      * @see CaptureRequest#EDGE_MODE
@@ -2154,7 +2155,8 @@
      * applied for reasonable preview quality.</p>
      * <p>This mode is guaranteed to be supported by devices that support either the
      * YUV_REPROCESSING or PRIVATE_REPROCESSING capabilities
-     * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} lists either of those capabilities).</p>
+     * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} lists either of those capabilities) and it will
+     * be the default mode for CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG template.</p>
      *
      * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
      * @see CaptureRequest#NOISE_REDUCTION_MODE
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index 82d3e0a..15c7aaf 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -520,6 +520,21 @@
     }
 
     /**
+     * Finishes enrollment and cancels the current auth token.
+     * @hide
+     */
+    @RequiresPermission(MANAGE_FINGERPRINT)
+    public int postEnroll() {
+        int result = 0;
+        if (mService != null) try {
+            result = mService.postEnroll(mToken);
+        } catch (RemoteException e) {
+            Log.w(TAG, "Remote exception in post enroll: ", e);
+        }
+        return result;
+    }
+
+    /**
      * Remove given fingerprint template from fingerprint hardware and/or protected storage.
      * @param fp the fingerprint item to remove
      * @param callback an optional callback to verify that fingerprint templates have been
diff --git a/core/java/android/hardware/fingerprint/IFingerprintDaemon.aidl b/core/java/android/hardware/fingerprint/IFingerprintDaemon.aidl
index 186d36e..9c13523 100644
--- a/core/java/android/hardware/fingerprint/IFingerprintDaemon.aidl
+++ b/core/java/android/hardware/fingerprint/IFingerprintDaemon.aidl
@@ -21,7 +21,7 @@
  * Communication channel from FingerprintService to FingerprintDaemon (fingerprintd)
  * @hide
  */
- 
+
 interface IFingerprintDaemon {
     int authenticate(long sessionId, int groupId);
     int cancelAuthentication();
@@ -34,4 +34,5 @@
     long openHal();
     int closeHal();
     void init(IFingerprintDaemonCallback callback);
+    int postEnroll();
 }
diff --git a/core/java/android/hardware/fingerprint/IFingerprintService.aidl b/core/java/android/hardware/fingerprint/IFingerprintService.aidl
index f596c93..5e233b8 100644
--- a/core/java/android/hardware/fingerprint/IFingerprintService.aidl
+++ b/core/java/android/hardware/fingerprint/IFingerprintService.aidl
@@ -54,6 +54,9 @@
     // Get a pre-enrollment authentication token
     long preEnroll(IBinder token);
 
+    // Finish an enrollment sequence and invalidate the authentication token
+    int postEnroll(IBinder token);
+
     // Determine if a user has at least one enrolled fingerprint
     boolean hasEnrolledFingerprints(int groupId, String opPackageName);
 
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
index d66e228..1408202 100644
--- a/core/java/android/os/storage/StorageVolume.java
+++ b/core/java/android/os/storage/StorageVolume.java
@@ -58,6 +58,9 @@
     // ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts.
     public static final String EXTRA_STORAGE_VOLUME = "storage_volume";
 
+    public static final int STORAGE_ID_INVALID = 0x00000000;
+    public static final int STORAGE_ID_PRIMARY = 0x00010001;
+
     public StorageVolume(String id, int storageId, File path, String description, boolean primary,
             boolean removable, boolean emulated, long mtpReserveSize, boolean allowMassStorage,
             long maxFileSize, UserHandle owner, String fsUuid, String state) {
diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java
index 91cb944..32f7bc9 100644
--- a/core/java/android/os/storage/VolumeInfo.java
+++ b/core/java/android/os/storage/VolumeInfo.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
-import android.mtp.MtpStorage;
 import android.net.Uri;
 import android.os.Environment;
 import android.os.Parcel;
@@ -147,15 +146,11 @@
     public String path;
     public String internalPath;
 
-    /** Framework state */
-    public final int mtpIndex;
-
-    public VolumeInfo(String id, int type, DiskInfo disk, String partGuid, int mtpIndex) {
+    public VolumeInfo(String id, int type, DiskInfo disk, String partGuid) {
         this.id = Preconditions.checkNotNull(id);
         this.type = type;
         this.disk = disk;
         this.partGuid = partGuid;
-        this.mtpIndex = mtpIndex;
     }
 
     public VolumeInfo(Parcel parcel) {
@@ -175,7 +170,6 @@
         fsLabel = parcel.readString();
         path = parcel.readString();
         internalPath = parcel.readString();
-        mtpIndex = parcel.readInt();
     }
 
     public static @NonNull String getEnvironmentForState(int state) {
@@ -305,10 +299,11 @@
     }
 
     public StorageVolume buildStorageVolume(Context context, int userId) {
+        final StorageManager storage = context.getSystemService(StorageManager.class);
+
         final boolean removable;
         final boolean emulated;
         final boolean allowMassStorage = false;
-        final int mtpStorageId = MtpStorage.getStorageIdForIndex(mtpIndex);
         final String envState = getEnvironmentForState(state);
 
         File userPath = getPathForUser(userId);
@@ -316,20 +311,24 @@
             userPath = new File("/dev/null");
         }
 
-        String description = getDescription();
-        if (description == null) {
-            description = getFsUuid();
-        }
-        if (description == null) {
-            description = context.getString(android.R.string.unknownName);
-        }
-
+        String description = null;
         long mtpReserveSize = 0;
         long maxFileSize = 0;
+        int mtpStorageId = StorageVolume.STORAGE_ID_INVALID;
 
         if (type == TYPE_EMULATED) {
             emulated = true;
-            mtpReserveSize = StorageManager.from(context).getStorageLowBytes(userPath);
+
+            final VolumeInfo privateVol = storage.findPrivateForEmulated(this);
+            if (privateVol != null) {
+                description = storage.getBestVolumeDescription(privateVol);
+            }
+
+            if (isPrimary()) {
+                mtpStorageId = StorageVolume.STORAGE_ID_PRIMARY;
+            }
+
+            mtpReserveSize = storage.getStorageLowBytes(userPath);
 
             if (ID_EMULATED_INTERNAL.equals(id)) {
                 removable = false;
@@ -341,6 +340,16 @@
             emulated = false;
             removable = true;
 
+            description = storage.getBestVolumeDescription(this);
+
+            if (isPrimary()) {
+                mtpStorageId = StorageVolume.STORAGE_ID_PRIMARY;
+            } else {
+                // Since MediaProvider currently persists this value, we need a
+                // value that is stable over time.
+                mtpStorageId = buildStableMtpStorageId(fsUuid);
+            }
+
             if ("vfat".equals(fsType)) {
                 maxFileSize = 4294967295L;
             }
@@ -349,11 +358,33 @@
             throw new IllegalStateException("Unexpected volume type " + type);
         }
 
+        if (description == null) {
+            description = context.getString(android.R.string.unknownName);
+        }
+
         return new StorageVolume(id, mtpStorageId, userPath, description, isPrimary(), removable,
                 emulated, mtpReserveSize, allowMassStorage, maxFileSize, new UserHandle(userId),
                 fsUuid, envState);
     }
 
+    public static int buildStableMtpStorageId(String fsUuid) {
+        if (TextUtils.isEmpty(fsUuid)) {
+            return StorageVolume.STORAGE_ID_INVALID;
+        } else {
+            int hash = 0;
+            for (int i = 0; i < fsUuid.length(); ++i) {
+                hash = 31 * hash + fsUuid.charAt(i);
+            }
+            hash = (hash ^ (hash << 16)) & 0xffff0000;
+            // Work around values that the spec doesn't allow, or that we've
+            // reserved for primary
+            if (hash == 0x00000000) hash = 0x00020000;
+            if (hash == 0x00010000) hash = 0x00020000;
+            if (hash == 0xffff0000) hash = 0xfffe0000;
+            return hash | 0x0001;
+        }
+    }
+
     // TODO: avoid this layering violation
     private static final String DOCUMENT_AUTHORITY = "com.android.externalstorage.documents";
     private static final String DOCUMENT_ROOT_PRIMARY_EMULATED = "primary";
@@ -402,7 +433,6 @@
         pw.println();
         pw.printPair("path", path);
         pw.printPair("internalPath", internalPath);
-        pw.printPair("mtpIndex", mtpIndex);
         pw.decreaseIndent();
         pw.println();
     }
@@ -469,6 +499,5 @@
         parcel.writeString(fsLabel);
         parcel.writeString(path);
         parcel.writeString(internalPath);
-        parcel.writeInt(mtpIndex);
     }
 }
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 8ce1cbf..d547a60 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -5957,7 +5957,9 @@
              */
             public static final CharSequence getTypeLabel(Resources res, int type,
                     CharSequence label) {
-                if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
+                if (type == TYPE_CUSTOM) {
+                    return (label != null ? label : "");
+                } else if (type == TYPE_ASSISTANT && !TextUtils.isEmpty(label)) {
                     return label;
                 } else {
                     final int labelRes = getTypeLabelResource(type);
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index caf15d1..82eb2c4 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1262,11 +1262,14 @@
     <bool name="config_sms_capable">true</bool>
 
     <!-- Default SMS Application. This will be the default SMS application when
-         the phone first boots. The user can then change the default app to oe
+         the phone first boots. The user can then change the default app to one
          of their choosing.
          This can be overridden for devices where a different default SMS
-         application is desired. -->
-    <string name="default_sms_application" translatable="false">com.android.mms</string>
+         application is desired.
+
+         If this string is empty or the specified package does not exist, then
+         the platform will search for an SMS app and use that (if there is one)-->
+    <string name="default_sms_application" translatable="false"></string>
 
     <!-- Default web browser.  This is the package name of the application that will
          be the default browser when the device first boots.  Afterwards the user
diff --git a/docs/html-intl/intl/es/preview/download.jd b/docs/html-intl/intl/es/preview/download.jd
index 8ba79c9..d71d8fd 100644
--- a/docs/html-intl/intl/es/preview/download.jd
+++ b/docs/html-intl/intl/es/preview/download.jd
@@ -265,8 +265,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html-intl/intl/ja/preview/download.jd b/docs/html-intl/intl/ja/preview/download.jd
index f95976a..67b1bc4 100644
--- a/docs/html-intl/intl/ja/preview/download.jd
+++ b/docs/html-intl/intl/ja/preview/download.jd
@@ -264,8 +264,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html-intl/intl/ko/preview/download.jd b/docs/html-intl/intl/ko/preview/download.jd
index 3ec5e03..ff9dd7e 100644
--- a/docs/html-intl/intl/ko/preview/download.jd
+++ b/docs/html-intl/intl/ko/preview/download.jd
@@ -265,8 +265,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html-intl/intl/pt-br/preview/download.jd b/docs/html-intl/intl/pt-br/preview/download.jd
index 5b7dc94..12ef194 100644
--- a/docs/html-intl/intl/pt-br/preview/download.jd
+++ b/docs/html-intl/intl/pt-br/preview/download.jd
@@ -265,8 +265,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html-intl/intl/ru/preview/download.jd b/docs/html-intl/intl/ru/preview/download.jd
index f7e0edd..13872d1 100644
--- a/docs/html-intl/intl/ru/preview/download.jd
+++ b/docs/html-intl/intl/ru/preview/download.jd
@@ -264,9 +264,11 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
-    </td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
+      </td>
   </tr>
 
 </table>
diff --git a/docs/html-intl/intl/zh-cn/preview/download.jd b/docs/html-intl/intl/zh-cn/preview/download.jd
index 262d10d..ba5249a 100644
--- a/docs/html-intl/intl/zh-cn/preview/download.jd
+++ b/docs/html-intl/intl/zh-cn/preview/download.jd
@@ -264,8 +264,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html-intl/intl/zh-tw/preview/download.jd b/docs/html-intl/intl/zh-tw/preview/download.jd
index e6ebda8..3b54080 100644
--- a/docs/html-intl/intl/zh-tw/preview/download.jd
+++ b/docs/html-intl/intl/zh-tw/preview/download.jd
@@ -264,8 +264,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/docs/html/preview/download.jd b/docs/html/preview/download.jd
index 0862d97..0dfabef 100644
--- a/docs/html/preview/download.jd
+++ b/docs/html/preview/download.jd
@@ -267,8 +267,10 @@
 
   <tr id="fugu">
     <td>Nexus Player <br>"fugu"</td>
-    <td>
-      <em>Coming soon</em>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
     </td>
   </tr>
 
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
index 6411066..5459bea 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
@@ -129,6 +129,12 @@
                 return;
             }
 
+            if (!"GCM".equalsIgnoreCase(params.getAlgorithm())) {
+                throw new InvalidAlgorithmParameterException(
+                        "Unsupported AlgorithmParameters algorithm: " + params.getAlgorithm()
+                        + ". Supported: GCM");
+            }
+
             GCMParameterSpec spec;
             try {
                 spec = params.getParameterSpec(GCMParameterSpec.class);
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreUnauthenticatedAESCipherSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreUnauthenticatedAESCipherSpi.java
index 486519c..1f1d36f 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreUnauthenticatedAESCipherSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreUnauthenticatedAESCipherSpi.java
@@ -197,6 +197,12 @@
             return;
         }
 
+        if (!"AES".equalsIgnoreCase(params.getAlgorithm())) {
+            throw new InvalidAlgorithmParameterException(
+                    "Unsupported AlgorithmParameters algorithm: " + params.getAlgorithm()
+                    + ". Supported: AES");
+        }
+
         IvParameterSpec ivSpec;
         try {
             ivSpec = params.getParameterSpec(IvParameterSpec.class);
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java
index 173d349..bdb1f58 100644
--- a/media/java/android/media/AudioDeviceInfo.java
+++ b/media/java/android/media/AudioDeviceInfo.java
@@ -105,6 +105,10 @@
      * A device type describing the auxiliary line-level connectors.
      */
     public static final int TYPE_AUX_LINE         = 19;
+    /**
+     * A device type connected over IP.
+     */
+    public static final int TYPE_IP               = 20;
 
     private final AudioDevicePort mPort;
 
@@ -250,6 +254,7 @@
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPDIF, TYPE_LINE_DIGITAL);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_FM, TYPE_FM);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_AUX_LINE, TYPE_AUX_LINE);
+        INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_IP, TYPE_IP);
 
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUILTIN_MIC, TYPE_BUILTIN_MIC);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO);
@@ -266,6 +271,7 @@
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_LINE, TYPE_LINE_ANALOG);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_SPDIF, TYPE_LINE_DIGITAL);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP);
+        INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_IP, TYPE_IP);
 
         // not covered here, legacy
         //AudioSystem.DEVICE_OUT_REMOTE_SUBMIX
@@ -292,6 +298,7 @@
         EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TV_TUNER, AudioSystem.DEVICE_IN_TV_TUNER);
         EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_OUT_TELEPHONY_TX);
         EXT_TO_INT_DEVICE_MAPPING.put(TYPE_AUX_LINE, AudioSystem.DEVICE_OUT_AUX_LINE);
+        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_OUT_IP);
     }
 }
 
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 373f3fd..acdadd7 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -317,6 +317,7 @@
     public static final int DEVICE_OUT_FM = 0x100000;
     public static final int DEVICE_OUT_AUX_LINE = 0x200000;
     public static final int DEVICE_OUT_SPEAKER_SAFE = 0x400000;
+    public static final int DEVICE_OUT_IP = 0x800000;
 
     public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
 
@@ -343,6 +344,7 @@
                                               DEVICE_OUT_FM |
                                               DEVICE_OUT_AUX_LINE |
                                               DEVICE_OUT_SPEAKER_SAFE |
+                                              DEVICE_OUT_IP |
                                               DEVICE_OUT_DEFAULT);
     public static final int DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP |
                                                    DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
@@ -381,6 +383,7 @@
     public static final int DEVICE_IN_SPDIF = DEVICE_BIT_IN | 0x10000;
     public static final int DEVICE_IN_BLUETOOTH_A2DP = DEVICE_BIT_IN | 0x20000;
     public static final int DEVICE_IN_LOOPBACK = DEVICE_BIT_IN | 0x40000;
+    public static final int DEVICE_IN_IP = DEVICE_BIT_IN | 0x80000;
     public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT;
 
     public static final int DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION |
@@ -402,6 +405,7 @@
                                              DEVICE_IN_SPDIF |
                                              DEVICE_IN_BLUETOOTH_A2DP |
                                              DEVICE_IN_LOOPBACK |
+                                             DEVICE_IN_IP |
                                              DEVICE_IN_DEFAULT);
     public static final int DEVICE_IN_ALL_SCO = DEVICE_IN_BLUETOOTH_SCO_HEADSET;
     public static final int DEVICE_IN_ALL_USB = (DEVICE_IN_USB_ACCESSORY |
@@ -436,6 +440,7 @@
     public static final String DEVICE_OUT_FM_NAME = "fm_transmitter";
     public static final String DEVICE_OUT_AUX_LINE_NAME = "aux_line";
     public static final String DEVICE_OUT_SPEAKER_SAFE_NAME = "speaker_safe";
+    public static final String DEVICE_OUT_IP_NAME = "ip";
 
     public static final String DEVICE_IN_COMMUNICATION_NAME = "communication";
     public static final String DEVICE_IN_AMBIENT_NAME = "ambient";
@@ -456,6 +461,7 @@
     public static final String DEVICE_IN_SPDIF_NAME = "spdif";
     public static final String DEVICE_IN_BLUETOOTH_A2DP_NAME = "bt_a2dp";
     public static final String DEVICE_IN_LOOPBACK_NAME = "loopback";
+    public static final String DEVICE_IN_IP_NAME = "ip";
 
     public static String getOutputDeviceName(int device)
     {
@@ -506,6 +512,8 @@
             return DEVICE_OUT_AUX_LINE_NAME;
         case DEVICE_OUT_SPEAKER_SAFE:
             return DEVICE_OUT_SPEAKER_SAFE_NAME;
+        case DEVICE_OUT_IP:
+            return DEVICE_OUT_IP_NAME;
         case DEVICE_OUT_DEFAULT:
         default:
             return Integer.toString(device);
@@ -553,6 +561,8 @@
             return DEVICE_IN_BLUETOOTH_A2DP_NAME;
         case DEVICE_IN_LOOPBACK:
             return DEVICE_IN_LOOPBACK_NAME;
+        case DEVICE_IN_IP:
+            return DEVICE_IN_IP_NAME;
         case DEVICE_IN_DEFAULT:
         default:
             return Integer.toString(device);
diff --git a/media/java/android/mtp/MtpStorage.java b/media/java/android/mtp/MtpStorage.java
index 3641ff5..6ca442c 100644
--- a/media/java/android/mtp/MtpStorage.java
+++ b/media/java/android/mtp/MtpStorage.java
@@ -53,18 +53,6 @@
         return mStorageId;
     }
 
-    /**
-     * Generates a storage ID for storage of given index.
-     * Index 0 is for primary external storage
-     *
-     * @return the storage ID
-     */
-    public static int getStorageIdForIndex(int index) {
-        // storage ID is 0x00010001 for primary storage,
-        // then 0x00020001, 0x00030001, etc. for secondary storages
-        return ((index + 1) << 16) + 1;
-    }
-
    /**
      * Returns the file path for the storage unit's storage in the file system
      *
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
index e083c9c..e89caf7 100644
--- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java
+++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
@@ -23,8 +23,11 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.net.ConnectivityManager;
+import android.net.wifi.WifiManager;
+import android.telephony.ServiceState;
 import android.telephony.SubscriptionInfo;
 import android.text.TextUtils;
 import android.text.method.SingleLineTransformationMethod;
@@ -48,6 +51,8 @@
 
     private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
 
+    private WifiManager mWifiManager;
+
     private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
         @Override
         public void onRefreshCarrierInfo() {
@@ -93,24 +98,46 @@
             a.recycle();
         }
         setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
+
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
     }
 
     protected void updateCarrierText() {
         boolean allSimsMissing = true;
+        boolean anySimReadyAndInService = false;
         CharSequence displayText = null;
 
         List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
         final int N = subs.size();
         if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N);
         for (int i = 0; i < N; i++) {
-            State simState = mKeyguardUpdateMonitor.getSimState(subs.get(i).getSubscriptionId());
+            int subId = subs.get(i).getSubscriptionId();
+            State simState = mKeyguardUpdateMonitor.getSimState(subId);
             CharSequence carrierName = subs.get(i).getCarrierName();
             CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
-            if (DEBUG) Log.d(TAG, "Handling " + simState + " " + carrierName);
+            if (DEBUG) {
+                Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
+            }
             if (carrierTextForSimState != null) {
                 allSimsMissing = false;
                 displayText = concatenate(displayText, carrierTextForSimState);
             }
+            if (simState == IccCardConstants.State.READY) {
+                ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId);
+                if (ss != null && ss.getDataRegState() == ServiceState.STATE_IN_SERVICE) {
+                    // hack for WFC (IWLAN) not turning off immediately once
+                    // Wi-Fi is disassociated or disabled
+                    if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
+                            || (mWifiManager.isWifiEnabled()
+                                    && mWifiManager.getConnectionInfo() != null
+                                    && mWifiManager.getConnectionInfo().getBSSID() != null)) {
+                        if (DEBUG) {
+                            Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
+                        }
+                        anySimReadyAndInService = true;
+                    }
+                }
+            }
         }
         if (allSimsMissing) {
             if (N != 0) {
@@ -152,7 +179,10 @@
                         getContext().getText(R.string.keyguard_missing_sim_message_short), text);
             }
         }
-        if (WirelessUtils.isAirplaneModeOn(mContext)) {
+
+        // APM (airplane mode) != no carrier state. There are carrier services
+        // (e.g. WFC = Wi-Fi calling) which may operate in APM.
+        if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
             displayText = getContext().getString(R.string.airplane_mode);
         }
         setText(displayText);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index a0174a7..581c15b 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -56,6 +56,7 @@
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback;
 import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
+import android.telephony.ServiceState;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
@@ -118,11 +119,13 @@
     private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327;
     private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
     private static final int MSG_AIRPLANE_MODE_CHANGED = 329;
+    private static final int MSG_SERVICE_STATE_CHANGE = 330;
 
     private static KeyguardUpdateMonitor sInstance;
 
     private final Context mContext;
     HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
+    HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();
 
     private int mRingMode;
     private int mPhoneState;
@@ -226,6 +229,9 @@
                 case MSG_AIRPLANE_MODE_CHANGED:
                     handleAirplaneModeChanged();
                     break;
+                case MSG_SERVICE_STATE_CHANGE:
+                    handleServiceStateChange(msg.arg1, (ServiceState) msg.obj);
+                    break;
             }
         }
     };
@@ -503,6 +509,16 @@
                 mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
             } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
                 dispatchBootCompleted();
+            } else if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) {
+                ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
+                int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
+                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+                if (DEBUG) {
+                    Log.v(TAG, "action " + action + " serviceState=" + serviceState + " subId="
+                            + subId);
+                }
+                mHandler.sendMessage(
+                        mHandler.obtainMessage(MSG_SERVICE_STATE_CHANGE, subId, 0, serviceState));
             }
         }
     };
@@ -738,6 +754,7 @@
         filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
         filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
         filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+        filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
         filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
         filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
         context.registerReceiver(mBroadcastReceiver, filter);
@@ -1058,6 +1075,30 @@
     }
 
     /**
+     * Handle {@link #MSG_SERVICE_STATE_CHANGE}
+     */
+    private void handleServiceStateChange(int subId, ServiceState serviceState) {
+        if (DEBUG) {
+            Log.d(TAG,
+                    "handleServiceStateChange(subId=" + subId + ", serviceState=" + serviceState);
+        }
+
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            Log.w(TAG, "invalid subId in handleServiceStateChange()");
+            return;
+        }
+
+        mServiceStates.put(subId, serviceState);
+
+        for (int j = 0; j < mCallbacks.size(); j++) {
+            KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get();
+            if (cb != null) {
+                cb.onRefreshCarrierInfo();
+            }
+        }
+    }
+
+    /**
      * Handle {@link #MSG_KEYGUARD_VISIBILITY_CHANGED}
      */
     private void handleKeyguardVisibilityChanged(int showing) {
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index ea032b3..f25236e 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -52,6 +52,7 @@
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_PRIVILEDGED_PHONE_STATE" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
     <uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 6acd137..9f6d8df 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -38,7 +38,9 @@
 import android.view.SurfaceHolder;
 import android.view.WindowManager;
 
+import java.io.FileDescriptor;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
@@ -147,6 +149,10 @@
         private static final int TRIANGLE_VERTICES_DATA_POS_OFFSET = 0;
         private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
 
+        private int mRotationAtLastSurfaceSizeUpdate = -1;
+        private int mDisplayWidthAtLastSurfaceSizeUpdate = -1;
+        private int mDisplayHeightAtLastSurfaceSizeUpdate = -1;
+
         public DrawableEngine() {
             super();
             setFixedSizeAllowed(true);
@@ -315,6 +321,9 @@
                 if (newRotation != mLastRotation) {
                     // Update surface size (if necessary)
                     updateSurfaceSize(getSurfaceHolder(), displayInfo);
+                    mRotationAtLastSurfaceSizeUpdate = newRotation;
+                    mDisplayWidthAtLastSurfaceSizeUpdate = displayInfo.logicalWidth;
+                    mDisplayHeightAtLastSurfaceSizeUpdate = displayInfo.logicalHeight;
                 }
                 SurfaceHolder sh = getSurfaceHolder();
                 final Rect frame = sh.getSurfaceFrame();
@@ -449,6 +458,37 @@
             }
         }
 
+        @Override
+        protected void dump(String prefix, FileDescriptor fd, PrintWriter out, String[] args) {
+            super.dump(prefix, fd, out, args);
+
+            out.print(prefix); out.println("ImageWallpaper.DrawableEngine:");
+            out.print(prefix); out.print(" mBackground="); out.print(mBackground);
+            out.print(" mBackgroundWidth="); out.print(mBackgroundWidth);
+            out.print(" mBackgroundHeight="); out.println(mBackgroundHeight);
+
+            out.print(prefix); out.print(" mLastRotation="); out.print(mLastRotation);
+            out.print(" mLastSurfaceWidth="); out.print(mLastSurfaceWidth);
+            out.print(" mLastSurfaceHeight="); out.println(mLastSurfaceHeight);
+
+            out.print(prefix); out.print(" mXOffset="); out.print(mXOffset);
+            out.print(" mYOffset="); out.println(mYOffset);
+
+            out.print(prefix); out.print(" mVisible="); out.print(mVisible);
+            out.print(" mRedrawNeeded="); out.print(mRedrawNeeded);
+            out.print(" mOffsetsChanged="); out.println(mOffsetsChanged);
+
+            out.print(prefix); out.print(" mLastXTranslation="); out.print(mLastXTranslation);
+            out.print(" mLastYTranslation="); out.print(mLastYTranslation);
+            out.print(" mScale="); out.println(mScale);
+
+            out.print(prefix); out.println(" DisplayInfo at last updateSurfaceSize:");
+            out.print(prefix);
+            out.print("  rotation="); out.print(mRotationAtLastSurfaceSizeUpdate);
+            out.print("  width="); out.print(mDisplayWidthAtLastSurfaceSizeUpdate);
+            out.print("  height="); out.println(mDisplayHeightAtLastSurfaceSizeUpdate);
+        }
+
         private void drawWallpaperWithCanvas(SurfaceHolder sh, int w, int h, int left, int top) {
             Canvas c = sh.lockCanvas();
             if (c != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index c33ef7c..3bfff2f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -144,7 +144,7 @@
             state.label = removeDoubleQuotes(cb.enabledDesc);
             signalContentDescription = cb.wifiSignalContentDescription;
         } else if (wifiNotConnected) {
-            state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_0);
+            state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_full_0);
             state.label = r.getString(R.string.quick_settings_wifi_label);
             signalContentDescription = r.getString(R.string.accessibility_no_wifi);
         } else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 08a6603..ccec759 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -44,6 +44,7 @@
     private int mClipTopOptimization;
     private static Rect mClipRect = new Rect();
     private boolean mWillBeGone;
+    private int mMinClipTopAmount = 0;
 
     public ExpandableView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -400,6 +401,14 @@
         mWillBeGone = willBeGone;
     }
 
+    public int getMinClipTopAmount() {
+        return mMinClipTopAmount;
+    }
+
+    public void setMinClipTopAmount(int minClipTopAmount) {
+        mMinClipTopAmount = minClipTopAmount;
+    }
+
     /**
      * A listener notifying when {@link #getActualHeight} changes.
      */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 20f4dc7..b996724 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -81,7 +81,6 @@
 import android.view.ThreadedRenderer;
 import android.view.VelocityTracker;
 import android.view.View;
-import android.view.ViewConfiguration;
 import android.view.ViewGroup.LayoutParams;
 import android.view.ViewStub;
 import android.view.WindowManager;
@@ -106,7 +105,6 @@
 import com.android.systemui.EventLogTags;
 import com.android.systemui.Prefs;
 import com.android.systemui.R;
-import com.android.systemui.SwipeHelper;
 import com.android.systemui.assist.AssistManager;
 import com.android.systemui.doze.DozeHost;
 import com.android.systemui.doze.DozeLog;
@@ -943,6 +941,7 @@
         addPostCollapseAction(new Runnable() {
             @Override
             public void run() {
+                mStackScroller.setDismissAllInProgress(false);
                 try {
                     mBarService.onClearAllNotifications(mCurrentUserId);
                 } catch (Exception ex) { }
@@ -957,12 +956,6 @@
         Runnable animationFinishAction = new Runnable() {
             @Override
             public void run() {
-                mStackScroller.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        mStackScroller.setDismissAllInProgress(false);
-                    }
-                });
                 animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
             }
         };
@@ -2145,11 +2138,13 @@
     }
 
     private void runPostCollapseRunnables() {
-        int size = mPostCollapseRunnables.size();
-        for (int i = 0; i < size; i++) {
-            mPostCollapseRunnables.get(i).run();
-        }
+        ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables);
         mPostCollapseRunnables.clear();
+        int size = clonedList.size();
+        for (int i = 0; i < size; i++) {
+            clonedList.get(i).run();
+        }
+
     }
 
     Animator mScrollViewAnim, mClearButtonAnim;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java
index 4a7ea96..3a97be6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java
@@ -43,6 +43,7 @@
     private int mTopPadding;
     private boolean mShadeExpanded;
     private float mMaxHeadsUpTranslation;
+    private boolean mDismissAllInProgress;
 
     public int getScrollY() {
         return mScrollY;
@@ -183,4 +184,12 @@
         HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry();
         return topEntry == null ? null : topEntry.entry.row;
     }
+
+    public void setDismissAllInProgress(boolean dismissAllInProgress) {
+        mDismissAllInProgress = dismissAllInProgress;
+    }
+
+    public boolean isDismissAllInProgress() {
+        return mDismissAllInProgress;
+    }
 }
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 bde07de..0d89b21 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -773,8 +773,7 @@
     }
 
     public boolean canChildBeDismissed(View v) {
-        final View veto = v.findViewById(R.id.veto);
-        return (veto != null && veto.getVisibility() != View.GONE);
+        return StackScrollAlgorithm.canChildBeDismissed(v);
     }
 
     @Override
@@ -2610,9 +2609,28 @@
     public void setDismissAllInProgress(boolean dismissAllInProgress) {
         mDismissAllInProgress = dismissAllInProgress;
         mDismissView.setDismissAllInProgress(dismissAllInProgress);
+        mAmbientState.setDismissAllInProgress(dismissAllInProgress);
         if (dismissAllInProgress) {
             disableClipOptimization();
         }
+        handleDismissAllClipping();
+    }
+
+    private void handleDismissAllClipping() {
+        final int count = getChildCount();
+        boolean previousChildWillBeDismissed = false;
+        for (int i = 0; i < count; i++) {
+            ExpandableView child = (ExpandableView) getChildAt(i);
+            if (child.getVisibility() == GONE) {
+                continue;
+            }
+            if (mDismissAllInProgress && previousChildWillBeDismissed) {
+                child.setMinClipTopAmount(child.getClipTopAmount());
+            } else {
+                child.setMinClipTopAmount(0);
+            }
+            previousChildWillBeDismissed = canChildBeDismissed(child);
+        }
     }
 
     private void disableClipOptimization() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
index 5c604b6..5d2e5b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -202,6 +202,7 @@
 
     private void updateClipping(StackScrollState resultState,
             StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
+        boolean dismissAllInProgress = ambientState.isDismissAllInProgress();
         float previousNotificationEnd = 0;
         float previousNotificationStart = 0;
         boolean previousNotificationIsSwiped = false;
@@ -237,16 +238,29 @@
             updateChildClippingAndBackground(state, newHeight, clipHeight,
                     newHeight - (previousNotificationStart - newYTranslation));
 
+            if (dismissAllInProgress) {
+                state.clipTopAmount = Math.max(child.getMinClipTopAmount(), state.clipTopAmount);
+            }
+
             if (!child.isTransparent()) {
                 // Only update the previous values if we are not transparent,
                 // otherwise we would clip to a transparent view.
-                previousNotificationStart = newYTranslation + state.clipTopAmount * state.scale;
-                previousNotificationEnd = newNotificationEnd;
-                previousNotificationIsSwiped = ambientState.getDraggedViews().contains(child);
+                if ((dismissAllInProgress && canChildBeDismissed(child))) {
+                    previousNotificationIsSwiped = true;
+                } else {
+                    previousNotificationIsSwiped = ambientState.getDraggedViews().contains(child);
+                    previousNotificationEnd = newNotificationEnd;
+                    previousNotificationStart = newYTranslation + state.clipTopAmount * state.scale;
+                }
             }
         }
     }
 
+    public static boolean canChildBeDismissed(View v) {
+        final View veto = v.findViewById(R.id.veto);
+        return (veto != null && veto.getVisibility() != View.GONE);
+    }
+
     /**
      * Updates the shadow outline and the clipping for a view.
      *
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
index a4ccfd1..7836411 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
@@ -157,6 +157,7 @@
         lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
         lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top);
         lp.gravity = Gravity.TOP;
+        lp.windowAnimations = -1;
         window.setAttributes(lp);
         window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
 
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogMotion.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogMotion.java
index 4bb1011..8144ea4 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogMotion.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogMotion.java
@@ -36,7 +36,6 @@
 
     private static final float ANIMATION_SCALE = 1.0f;
     private static final int PRE_DISMISS_DELAY = 50;
-    private static final int POST_SHOW_DELAY = 200;
 
     private final Dialog mDialog;
     private final View mDialogView;
@@ -70,12 +69,7 @@
                 if (D.BUG) Log.d(TAG, "mDialog.onShow");
                 final int h = mDialogView.getHeight();
                 mDialogView.setTranslationY(-h);
-                mHandler.postDelayed(new Runnable() {
-                    @Override
-                    public void run() {
-                        startShowAnimation();
-                    }
-                }, POST_SHOW_DELAY);
+                startShowAnimation();
             }
         });
     }
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 894f513..25bd787 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -31,6 +31,7 @@
 import android.annotation.Nullable;
 import android.app.ActivityManagerNative;
 import android.app.AppOpsManager;
+import android.app.IActivityManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -39,10 +40,10 @@
 import android.content.ServiceConnection;
 import android.content.pm.IPackageMoveObserver;
 import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
 import android.content.pm.UserInfo;
 import android.content.res.Configuration;
 import android.content.res.ObbInfo;
-import android.mtp.MtpStorage;
 import android.net.Uri;
 import android.os.Binder;
 import android.os.DropBoxManager;
@@ -53,7 +54,6 @@
 import android.os.HandlerThread;
 import android.os.IBinder;
 import android.os.Looper;
-import android.os.Looper;
 import android.os.Message;
 import android.os.Process;
 import android.os.RemoteCallbackList;
@@ -73,6 +73,7 @@
 import android.os.storage.StorageVolume;
 import android.os.storage.VolumeInfo;
 import android.os.storage.VolumeRecord;
+import android.provider.MediaStore;
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
@@ -176,7 +177,6 @@
         }
     }
 
-    private static final boolean LOCAL_LOGD = false;
     private static final boolean DEBUG_EVENTS = false;
     private static final boolean DEBUG_OBB = false;
 
@@ -402,16 +402,6 @@
         }
     }
 
-    private static int sNextMtpIndex = 1;
-
-    private static int allocateMtpIndex(String volId) {
-        if (VolumeInfo.ID_EMULATED_INTERNAL.equals(volId)) {
-            return 0;
-        } else {
-            return sNextMtpIndex++;
-        }
-    }
-
     /** List of crypto types.
       * These must match CRYPT_TYPE_XXX in cryptfs.h AND their
       * corresponding commands in CommandListener.cpp */
@@ -733,16 +723,36 @@
         MountServiceIdler.scheduleIdlePass(mContext);
     }
 
+    /**
+     * MediaProvider has a ton of code that makes assumptions about storage
+     * paths never changing, so we outright kill them to pick up new state.
+     */
+    @Deprecated
+    private void killMediaProvider() {
+        final ProviderInfo provider = mPms.resolveContentProvider(MediaStore.AUTHORITY, 0,
+                UserHandle.USER_OWNER);
+        if (provider != null) {
+            final IActivityManager am = ActivityManagerNative.getDefault();
+            try {
+                am.killApplicationWithAppId(provider.applicationInfo.packageName,
+                        UserHandle.getAppId(provider.applicationInfo.uid), "vold reset");
+            } catch (RemoteException e) {
+            }
+        }
+    }
+
     private void resetIfReadyAndConnectedLocked() {
         Slog.d(TAG, "Thinking about reset, mSystemReady=" + mSystemReady
                 + ", mDaemonConnected=" + mDaemonConnected);
         if (mSystemReady && mDaemonConnected) {
+            killMediaProvider();
+
             mDisks.clear();
             mVolumes.clear();
 
             // Create a stub volume that represents internal storage
             final VolumeInfo internal = new VolumeInfo(VolumeInfo.ID_PRIVATE_INTERNAL,
-                    VolumeInfo.TYPE_PRIVATE, null, null, 0);
+                    VolumeInfo.TYPE_PRIVATE, null, null);
             internal.state = VolumeInfo.STATE_MOUNTED;
             internal.path = Environment.getDataDirectory().getAbsolutePath();
             mVolumes.put(internal.id, internal);
@@ -967,8 +977,7 @@
                 final String partGuid = TextUtils.nullIfEmpty(cooked[4]);
 
                 final DiskInfo disk = mDisks.get(diskId);
-                final int mtpIndex = allocateMtpIndex(id);
-                final VolumeInfo vol = new VolumeInfo(id, type, disk, partGuid, mtpIndex);
+                final VolumeInfo vol = new VolumeInfo(id, type, disk, partGuid);
                 mVolumes.put(id, vol);
                 onVolumeCreatedLocked(vol);
                 break;
@@ -1617,7 +1626,9 @@
         waitForReady();
 
         try {
-            final NativeDaemonEvent res = mConnector.execute("volume", "benchmark", volId);
+            // TODO: make benchmark async so we don't block other commands
+            final NativeDaemonEvent res = mConnector.execute(3 * DateUtils.MINUTE_IN_MILLIS,
+                    "volume", "benchmark", volId);
             return Long.parseLong(res.getMessage());
         } catch (NativeDaemonTimeoutException e) {
             return Long.MAX_VALUE;
@@ -2604,7 +2615,7 @@
             final String uuid = null;
             final String state = Environment.MEDIA_REMOVED;
 
-            res.add(0, new StorageVolume(id, MtpStorage.getStorageIdForIndex(0), path,
+            res.add(0, new StorageVolume(id, StorageVolume.STORAGE_ID_INVALID, path,
                     description, primary, removable, emulated, mtpReserveSize,
                     allowMassStorage, maxFileSize, owner, uuid, state));
         }
diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java
index e7979e4..519a2a3 100644
--- a/services/core/java/com/android/server/NativeDaemonConnector.java
+++ b/services/core/java/com/android/server/NativeDaemonConnector.java
@@ -69,7 +69,7 @@
 
     private AtomicInteger mSequenceNumber;
 
-    private static final int DEFAULT_TIMEOUT = 1 * 60 * 1000; /* 1 minute */
+    private static final long DEFAULT_TIMEOUT = 1 * 60 * 1000; /* 1 minute */
     private static final long WARN_EXECUTE_DELAY_MS = 500; /* .5 sec */
 
     /** Lock held whenever communicating with native daemon. */
@@ -337,7 +337,12 @@
      */
     public NativeDaemonEvent execute(String cmd, Object... args)
             throws NativeDaemonConnectorException {
-        final NativeDaemonEvent[] events = executeForList(cmd, args);
+        return execute(DEFAULT_TIMEOUT, cmd, args);
+    }
+
+    public NativeDaemonEvent execute(long timeoutMs, String cmd, Object... args)
+            throws NativeDaemonConnectorException {
+        final NativeDaemonEvent[] events = executeForList(timeoutMs, cmd, args);
         if (events.length != 1) {
             throw new NativeDaemonConnectorException(
                     "Expected exactly one response, but received " + events.length);
@@ -372,7 +377,7 @@
      */
     public NativeDaemonEvent[] executeForList(String cmd, Object... args)
             throws NativeDaemonConnectorException {
-            return execute(DEFAULT_TIMEOUT, cmd, args);
+        return executeForList(DEFAULT_TIMEOUT, cmd, args);
     }
 
     /**
@@ -387,7 +392,7 @@
      *             {@link NativeDaemonEvent#isClassClientError()} or
      *             {@link NativeDaemonEvent#isClassServerError()}.
      */
-    public NativeDaemonEvent[] execute(int timeout, String cmd, Object... args)
+    public NativeDaemonEvent[] executeForList(long timeoutMs, String cmd, Object... args)
             throws NativeDaemonConnectorException {
         final long startTime = SystemClock.elapsedRealtime();
 
@@ -418,7 +423,7 @@
 
         NativeDaemonEvent event = null;
         do {
-            event = mResponseQueue.remove(sequenceNumber, timeout, logCmd);
+            event = mResponseQueue.remove(sequenceNumber, timeoutMs, logCmd);
             if (event == null) {
                 loge("timed-out waiting for response to " + logCmd);
                 throw new NativeDaemonTimeoutException(logCmd, event);
@@ -606,7 +611,7 @@
 
         // note that the timeout does not count time in deep sleep.  If you don't want
         // the device to sleep, hold a wakelock
-        public NativeDaemonEvent remove(int cmdNum, int timeoutMs, String logCmd) {
+        public NativeDaemonEvent remove(int cmdNum, long timeoutMs, String logCmd) {
             PendingCmd found = null;
             synchronized (mPendingCmds) {
                 for (PendingCmd pendingCmd : mPendingCmds) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 8c3a950..31cdcd5 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -2963,6 +2963,7 @@
         r.state = ActivityState.FINISHING;
 
         if (mode == FINISH_IMMEDIATELY
+                || (mode == FINISH_AFTER_PAUSE && prevState == ActivityState.PAUSED)
                 || prevState == ActivityState.STOPPED
                 || prevState == ActivityState.INITIALIZING) {
             // If this activity is already stopped, we can just finish
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 1be3267..4d8d105 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -301,6 +301,20 @@
         return 0;
     }
 
+    public int startPostEnroll(IBinder token) {
+        IFingerprintDaemon daemon = getFingerprintDaemon();
+        if (daemon == null) {
+            Slog.w(TAG, "startPostEnroll: no fingeprintd!");
+            return 0;
+        }
+        try {
+            return daemon.postEnroll();
+        } catch (RemoteException e) {
+            Slog.e(TAG, "startPostEnroll failed", e);
+        }
+        return 0;
+    }
+
     private void stopPendingOperations() {
         if (mEnrollClient != null) {
             stopEnrollment(mEnrollClient.token, true);
@@ -539,8 +553,8 @@
                 }
             } else {
                 result = true; // client not listening
-            }
-            if (fpId <= 0) {
+	    }
+	    if (fpId == 0) {
                 FingerprintUtils.vibrateFingerprintError(getContext());
                 result |= handleFailedAttempt(this);
             } else {
@@ -635,6 +649,12 @@
         }
 
         @Override // Binder call
+        public int postEnroll(IBinder token) {
+            checkPermission(MANAGE_FINGERPRINT);
+            return startPostEnroll(token);
+        }
+
+        @Override // Binder call
         public void enroll(final IBinder token, final byte[] cryptoToken, final int groupId,
                 final IFingerprintServiceReceiver receiver, final int flags) {
             checkPermission(MANAGE_FINGERPRINT);
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintUtils.java b/services/core/java/com/android/server/fingerprint/FingerprintUtils.java
index 1e6e105..d274412 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintUtils.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintUtils.java
@@ -56,7 +56,7 @@
     }
 
     public void addFingerprintForUser(Context ctx, int fingerId, int userId) {
-        getStateForUser(ctx, userId).addFingerprint(fingerId);
+        getStateForUser(ctx, userId).addFingerprint(fingerId, userId);
     }
 
     public void removeFingerprintIdForUser(Context ctx, int fingerId, int userId) {
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java b/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java
index 902d970..0976a22 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java
@@ -68,9 +68,9 @@
         }
     }
 
-    public void addFingerprint(int fingerId) {
+    public void addFingerprint(int fingerId, int groupId) {
         synchronized (this) {
-            mFingerprints.add(new Fingerprint(getDefaultFingerprintName(fingerId), 0, fingerId, 0));
+            mFingerprints.add(new Fingerprint(getUniqueName(), groupId, fingerId, 0));
             scheduleWriteStateLocked();
         }
     }
@@ -107,8 +107,30 @@
         }
     }
 
-    private String getDefaultFingerprintName(int fingerId) {
-        return mCtx.getString(com.android.internal.R.string.fingerprint_name_template, fingerId);
+    /**
+     * Finds a unique name for the given fingerprint
+     * @return unique name
+     */
+    private String getUniqueName() {
+        int guess = 1;
+        while (true) {
+            // Not the most efficient algorithm in the world, but there shouldn't be more than 10
+            String name = mCtx.getString(com.android.internal.R.string.fingerprint_name_template,
+                    guess);
+            if (isUnique(name)) {
+                return name;
+            }
+            guess++;
+        }
+    }
+
+    private boolean isUnique(String name) {
+        for (Fingerprint fp : mFingerprints) {
+            if (fp.getName().equals(name)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     private static File getFileForUser(int userId) {
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index e756a57..4569549 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -921,7 +921,8 @@
      */
     public void registerCallback(Callback callback, Handler handler) {
         unregisterCallback(callback);
-        if (callback != null && handler != null) {
+        // Don't allow new callback registration if the call is already being destroyed.
+        if (callback != null && handler != null && mState != STATE_DISCONNECTED) {
             mCallbackRecords.add(new CallbackRecord<Callback>(callback, handler));
         }
     }
@@ -932,7 +933,8 @@
      * @param callback A {@code Callback}.
      */
     public void unregisterCallback(Callback callback) {
-        if (callback != null) {
+        // Don't allow callback deregistration if the call is already being destroyed.
+        if (callback != null && mState != STATE_DISCONNECTED) {
             for (CallbackRecord<Callback> record : mCallbackRecords) {
                 if (record.getCallback() == callback) {
                     mCallbackRecords.remove(record);
@@ -1080,7 +1082,6 @@
         // DISCONNECTED Call while still relying on the existence of that Call in the Phone's list.
         if (mState == STATE_DISCONNECTED) {
             fireCallDestroyed();
-            mPhone.internalRemoveCall(this);
         }
     }
 
@@ -1096,7 +1097,6 @@
             mState = Call.STATE_DISCONNECTED;
             fireStateChanged(mState);
             fireCallDestroyed();
-            mPhone.internalRemoveCall(this);
         }
     }
 
@@ -1192,13 +1192,42 @@
     }
 
     private void fireCallDestroyed() {
-        for (CallbackRecord<Callback> record: mCallbackRecords) {
-            final Call call = this;
+        /**
+         * To preserve the ordering of the Call's onCallDestroyed callback and Phone's
+         * onCallRemoved callback, we remove this call from the Phone's record
+         * only once all of the registered onCallDestroyed callbacks are executed.
+         * All the callbacks get removed from our records as a part of this operation
+         * since onCallDestroyed is the final callback.
+         */
+        final Call call = this;
+        if (mCallbackRecords.isEmpty()) {
+            // No callbacks registered, remove the call from Phone's record.
+            mPhone.internalRemoveCall(call);
+        }
+        for (final CallbackRecord<Callback> record : mCallbackRecords) {
             final Callback callback = record.getCallback();
             record.getHandler().post(new Runnable() {
                 @Override
                 public void run() {
-                    callback.onCallDestroyed(call);
+                    boolean isFinalRemoval = false;
+                    RuntimeException toThrow = null;
+                    try {
+                        callback.onCallDestroyed(call);
+                    } catch (RuntimeException e) {
+                            toThrow = e;
+                    }
+                    synchronized(Call.this) {
+                        mCallbackRecords.remove(record);
+                        if (mCallbackRecords.isEmpty()) {
+                            isFinalRemoval = true;
+                        }
+                    }
+                    if (isFinalRemoval) {
+                        mPhone.internalRemoveCall(call);
+                    }
+                    if (toThrow != null) {
+                        throw toThrow;
+                    }
                 }
             });
         }
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index fa1ed54..f4a6064 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -335,7 +335,7 @@
      *                 onSubscriptionsChanged overridden.
      */
     public void addOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) {
-        String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+        String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
         if (DBG) {
             logd("register OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
                     + " listener=" + listener);
@@ -361,7 +361,7 @@
      * @param listener that is to be unregistered.
      */
     public void removeOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) {
-        String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+        String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
         if (DBG) {
             logd("unregister OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
                     + " listener=" + listener);
@@ -603,7 +603,7 @@
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
                 // FIXME: This returns 1 on success, 0 on error should should we return it?
-                iSub.addSubInfoRecord(iccId, slotId, mContext.getOpPackageName());
+                iSub.addSubInfoRecord(iccId, slotId);
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -633,7 +633,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                result = iSub.setIconTint(tint, subId, mContext.getOpPackageName());
+                result = iSub.setIconTint(tint, subId);
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -678,8 +678,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                result = iSub.setDisplayNameUsingSrc(displayName, subId, nameSource,
-                        mContext.getOpPackageName());
+                result = iSub.setDisplayNameUsingSrc(displayName, subId, nameSource);
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -707,7 +706,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                result = iSub.setDisplayNumber(number, subId, mContext.getOpPackageName());
+                result = iSub.setDisplayNumber(number, subId);
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -736,7 +735,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                result = iSub.setDataRoaming(roaming, subId, mContext.getOpPackageName());
+                result = iSub.setDataRoaming(roaming, subId);
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -975,7 +974,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                iSub.clearSubInfo(mContext.getOpPackageName());
+                iSub.clearSubInfo();
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -1009,7 +1008,7 @@
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
             if (iSub != null) {
-                iSub.clearDefaultsForInactiveSubIds(mContext.getOpPackageName());
+                iSub.clearDefaultsForInactiveSubIds();
             }
         } catch (RemoteException ex) {
             // ignore it
@@ -1153,4 +1152,3 @@
         return false;
     }
 }
-
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 918a2eb..0555121 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -83,7 +83,7 @@
     List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage);
 
     /**
-     * @param callingPackage The package maing the call.
+     * @param callingPackage The package making the call.
      * @return the number of active subscriptions
      */
     int getActiveSubInfoCount(String callingPackage);
@@ -97,57 +97,50 @@
      * Add a new SubscriptionInfo to subinfo database if needed
      * @param iccId the IccId of the SIM card
      * @param slotId the slot which the SIM is inserted
-     * @param callingPackage The package maing the call.
      * @return the URL of the newly created row or the updated row
      */
-    int addSubInfoRecord(String iccId, int slotId, String callingPackage);
+    int addSubInfoRecord(String iccId, int slotId);
 
     /**
      * Set SIM icon tint color by simInfo index
      * @param tint the icon tint color of the SIM
      * @param subId the unique SubscriptionInfo index in database
-     * @param callingPackage The package maing the call.
      * @return the number of records updated
      */
-    int setIconTint(int tint, int subId, String callingPackage);
+    int setIconTint(int tint, int subId);
 
     /**
      * Set display name by simInfo index
      * @param displayName the display name of SIM card
      * @param subId the unique SubscriptionInfo index in database
-     * @param callingPackage The package maing the call.
      * @return the number of records updated
      */
-    int setDisplayName(String displayName, int subId, String callingPackage);
+    int setDisplayName(String displayName, int subId);
 
     /**
      * Set display name by simInfo index with name source
      * @param displayName the display name of SIM card
      * @param subId the unique SubscriptionInfo index in database
      * @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT
-     * @param callingPackage The package maing the call.
      * @return the number of records updated
      */
-    int setDisplayNameUsingSrc(String displayName, int subId, long nameSource,
-            String callingPackage);
+    int setDisplayNameUsingSrc(String displayName, int subId, long nameSource);
 
     /**
      * Set phone number by subId
      * @param number the phone number of the SIM
      * @param subId the unique SubscriptionInfo index in database
-     * @param callingPackage The package maing the call.
      * @return the number of records updated
      */
-    int setDisplayNumber(String number, int subId, String callingPackage);
+    int setDisplayNumber(String number, int subId);
 
     /**
      * Set data roaming by simInfo index
      * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming
-     * @param callingPackage The package maing the call.
      * @param subId the unique SubscriptionInfo index in database
      * @return the number of records updated
      */
-    int setDataRoaming(int roaming, int subId, String callingPackage);
+    int setDataRoaming(int roaming, int subId);
 
     int getSlotId(int subId);
 
@@ -155,7 +148,7 @@
 
     int getDefaultSubId();
 
-    int clearSubInfo(String callingPackage);
+    int clearSubInfo();
 
     int getPhoneId(int subId);
 
@@ -175,7 +168,7 @@
 
     void setDefaultSmsSubId(int subId);
 
-    void clearDefaultsForInactiveSubIds(String callingPackage);
+    void clearDefaultsForInactiveSubIds();
 
     int[] getActiveSubIdList();