Merge "Doze: Don't block pickup pulses on a proximity check." into lmp-mr1-dev
diff --git a/Android.mk b/Android.mk
index 39ddb55..ba45e6f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -204,8 +204,8 @@
 	core/java/android/os/IUpdateLock.aidl \
 	core/java/android/os/IUserManager.aidl \
 	core/java/android/os/IVibratorService.aidl \
-	core/java/android/service/carriermessaging/ICarrierMessagingCallback.aidl \
-	core/java/android/service/carriermessaging/ICarrierMessagingService.aidl \
+	core/java/android/service/carrier/ICarrierMessagingCallback.aidl \
+	core/java/android/service/carrier/ICarrierMessagingService.aidl \
 	core/java/android/service/notification/INotificationListener.aidl \
 	core/java/android/service/notification/IStatusBarNotificationHolder.aidl \
 	core/java/android/service/notification/IConditionListener.aidl \
@@ -524,8 +524,7 @@
 	frameworks/base/core/java/android/view/textservice/SpellCheckerInfo.aidl \
 	frameworks/base/core/java/android/view/textservice/SentenceSuggestionsInfo.aidl \
 	frameworks/base/core/java/android/view/textservice/SuggestionsInfo.aidl \
-	frameworks/base/core/java/android/service/carriermessaging/MessagePdu.aidl \
-	frameworks/base/core/java/android/service/carriermessaging/CarrierMessagingService.aidl \
+	frameworks/base/core/java/android/service/carrier/MessagePdu.aidl \
 	frameworks/base/core/java/android/service/notification/StatusBarNotification.aidl \
 	frameworks/base/core/java/android/speech/tts/Voice.aidl \
 	frameworks/base/core/java/android/app/usage/UsageEvents.aidl \
diff --git a/api/current.txt b/api/current.txt
index 53aa4a2..5a17f6f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8782,11 +8782,9 @@
     field public static final java.lang.String FEATURE_CAMERA = "android.hardware.camera";
     field public static final java.lang.String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
     field public static final java.lang.String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
-    field public static final java.lang.String FEATURE_CAMERA_CAPABILITY_BURST_CAPTURE = "android.hardware.camera.capability.burst_capture";
     field public static final java.lang.String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = "android.hardware.camera.capability.manual_post_processing";
     field public static final java.lang.String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = "android.hardware.camera.capability.manual_sensor";
     field public static final java.lang.String FEATURE_CAMERA_CAPABILITY_RAW = "android.hardware.camera.capability.raw";
-    field public static final java.lang.String FEATURE_CAMERA_CAPABILITY_READ_SENSOR_SETTINGS = "android.hardware.camera.capability.read_sensor_settings";
     field public static final java.lang.String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
     field public static final java.lang.String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
     field public static final java.lang.String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
@@ -26914,71 +26912,46 @@
 
 }
 
-package android.service.carriermessaging {
+package android.service.carrier {
 
   public abstract class CarrierMessagingService extends android.app.Service {
     ctor public CarrierMessagingService();
     method public android.os.IBinder onBind(android.content.Intent);
-    method public int onDownloadMms(android.net.Uri, java.lang.String);
-    method public boolean onFilterSms(android.service.carriermessaging.MessagePdu, java.lang.String, int);
-    method public android.service.carriermessaging.CarrierMessagingService.SendSmsResponse onSendDataSms(byte[], java.lang.String, java.lang.String, int);
-    method public android.service.carriermessaging.CarrierMessagingService.SendMmsResult onSendMms(android.net.Uri, java.lang.String);
-    method public java.util.List<android.service.carriermessaging.CarrierMessagingService.SendSmsResponse> onSendMultipartTextSms(java.util.List<java.lang.String>, java.lang.String, java.lang.String);
-    method public android.service.carriermessaging.CarrierMessagingService.SendSmsResponse onSendTextSms(java.lang.String, java.lang.String, java.lang.String);
+    method public void onDownloadMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Integer>);
+    method public void onFilterSms(android.service.carrier.MessagePdu, java.lang.String, int, int, android.service.carrier.CarrierMessagingService.ResultCallback<java.lang.Boolean>);
+    method public void onSendDataSms(byte[], int, java.lang.String, int, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
+    method public void onSendMms(android.net.Uri, int, android.net.Uri, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendMmsResult>);
+    method public void onSendMultipartTextSms(java.util.List<java.lang.String>, int, java.lang.String, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendMultipartSmsResult>);
+    method public void onSendTextSms(java.lang.String, int, java.lang.String, android.service.carrier.CarrierMessagingService.ResultCallback<android.service.carrier.CarrierMessagingService.SendSmsResult>);
     field public static final int DOWNLOAD_STATUS_ERROR = 2; // 0x2
     field public static final int DOWNLOAD_STATUS_OK = 0; // 0x0
     field public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1; // 0x1
     field public static final int SEND_STATUS_ERROR = 2; // 0x2
     field public static final int SEND_STATUS_OK = 0; // 0x0
     field public static final int SEND_STATUS_RETRY_ON_CARRIER_NETWORK = 1; // 0x1
-    field public static final java.lang.String SERVICE_INTERFACE = "android.service.carriermessaging.CarrierMessagingService";
+    field public static final java.lang.String SERVICE_INTERFACE = "android.service.carrier.CarrierMessagingService";
+  }
+
+  public static abstract interface CarrierMessagingService.ResultCallback {
+    method public abstract void onReceiveResult(T) throws android.os.RemoteException;
   }
 
   public static final class CarrierMessagingService.SendMmsResult {
     ctor public CarrierMessagingService.SendMmsResult(int, byte[]);
-    method public int getResult();
     method public byte[] getSendConfPdu();
+    method public int getSendStatus();
   }
 
-  public static final class CarrierMessagingService.SendSmsResponse implements android.os.Parcelable {
-    ctor public CarrierMessagingService.SendSmsResponse(int, byte[], int);
-    method public int describeContents();
-    method public byte[] getAckPdu();
-    method public int getErrorCode();
+  public static final class CarrierMessagingService.SendMultipartSmsResult {
+    ctor public CarrierMessagingService.SendMultipartSmsResult(int, int[]);
+    method public int[] getMessageRefs();
+    method public int getSendStatus();
+  }
+
+  public static final class CarrierMessagingService.SendSmsResult {
+    ctor public CarrierMessagingService.SendSmsResult(int, int);
     method public int getMessageRef();
-    method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.service.carriermessaging.CarrierMessagingService.SendSmsResponse> CREATOR;
-  }
-
-  public abstract interface ICarrierMessagingCallback implements android.os.IInterface {
-    method public abstract void onDownloadMmsComplete(int) throws android.os.RemoteException;
-    method public abstract void onFilterComplete(boolean) throws android.os.RemoteException;
-    method public abstract void onSendMmsComplete(int, byte[]) throws android.os.RemoteException;
-    method public abstract void onSendMultipartSmsComplete(int, java.util.List<android.service.carriermessaging.CarrierMessagingService.SendSmsResponse>) throws android.os.RemoteException;
-    method public abstract void onSendSmsComplete(int, android.service.carriermessaging.CarrierMessagingService.SendSmsResponse) throws android.os.RemoteException;
-  }
-
-  public static abstract class ICarrierMessagingCallback.Stub extends android.os.Binder implements android.service.carriermessaging.ICarrierMessagingCallback {
-    ctor public ICarrierMessagingCallback.Stub();
-    method public android.os.IBinder asBinder();
-    method public static android.service.carriermessaging.ICarrierMessagingCallback asInterface(android.os.IBinder);
-    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
-  }
-
-  public abstract interface ICarrierMessagingService implements android.os.IInterface {
-    method public abstract void downloadMms(android.net.Uri, java.lang.String, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-    method public abstract void filterSms(android.service.carriermessaging.MessagePdu, java.lang.String, int, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-    method public abstract void sendDataSms(byte[], java.lang.String, java.lang.String, int, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-    method public abstract void sendMms(android.net.Uri, java.lang.String, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-    method public abstract void sendMultipartTextSms(java.util.List<java.lang.String>, java.lang.String, java.lang.String, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-    method public abstract void sendTextSms(java.lang.String, java.lang.String, java.lang.String, android.service.carriermessaging.ICarrierMessagingCallback) throws android.os.RemoteException;
-  }
-
-  public static abstract class ICarrierMessagingService.Stub extends android.os.Binder implements android.service.carriermessaging.ICarrierMessagingService {
-    ctor public ICarrierMessagingService.Stub();
-    method public android.os.IBinder asBinder();
-    method public static android.service.carriermessaging.ICarrierMessagingService asInterface(android.os.IBinder);
-    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+    method public int getSendStatus();
   }
 
   public final class MessagePdu implements android.os.Parcelable {
@@ -26986,7 +26959,7 @@
     method public int describeContents();
     method public java.util.List<byte[]> getPdus();
     method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.service.carriermessaging.MessagePdu> CREATOR;
+    field public static final android.os.Parcelable.Creator<android.service.carrier.MessagePdu> CREATOR;
   }
 
 }
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java
index a55cc2b..7a80936 100644
--- a/core/java/android/app/backup/WallpaperBackupHelper.java
+++ b/core/java/android/app/backup/WallpaperBackupHelper.java
@@ -102,9 +102,8 @@
         final Display d = wm.getDefaultDisplay();
         final Point size = new Point();
         d.getSize(size);
-        mDesiredMinWidth = size.x;
+        mDesiredMinWidth = Math.min(size.x, size.y);
         mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight();
-
         if (mDesiredMinHeight <= 0) {
             mDesiredMinHeight = size.y;
         }
@@ -149,9 +148,13 @@
                         // We accept any wallpaper that is at least as wide as our preference
                         // (i.e. wide enough to fill the screen), and is within a comfortable
                         // factor of the target height, to avoid significant clipping/scaling/
-                        // letterboxing.
+                        // letterboxing.  At this point we know that mDesiredMinWidth is the
+                        // smallest dimension, regardless of current orientation, so we can
+                        // safely require that the candidate's width and height both exceed
+                        // that hard minimum.
                         final double heightRatio = mDesiredMinHeight / options.outHeight;
                         if (options.outWidth < mDesiredMinWidth
+                                || options.outHeight < mDesiredMinWidth
                                 || heightRatio >= MAX_HEIGHT_RATIO
                                 || heightRatio <= MIN_HEIGHT_RATIO) {
                             // Not wide enough for the screen, or too short/tall to be a good fit
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 5c705e6..e9f7c50 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1078,26 +1078,6 @@
             "android.hardware.camera.capability.raw";
 
     /**
-     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
-     * of the cameras on the device supports the
-     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE BURST_CAPTURE}
-     * capability level.
-     */
-    @SdkConstant(SdkConstantType.FEATURE)
-    public static final String FEATURE_CAMERA_CAPABILITY_BURST_CAPTURE =
-            "android.hardware.camera.capability.burst_capture";
-
-    /**
-     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
-     * of the cameras on the device supports the
-     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS READ_SENSOR_SETTINGS}
-     * capability level.
-     */
-    @SdkConstant(SdkConstantType.FEATURE)
-    public static final String FEATURE_CAMERA_CAPABILITY_READ_SENSOR_SETTINGS =
-            "android.hardware.camera.capability.read_sensor_settings";
-
-    /**
      * Feature for {@link #getSystemAvailableFeatures} and
      * {@link #hasSystemFeature}: The device is capable of communicating with
      * consumer IR devices.
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 82da7c5..d7d9e8b 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -3528,6 +3528,10 @@
             outError[0] = "<provider> does not include authorities attribute";
             return null;
         }
+        if (cpname.length() <= 0) {
+            outError[0] = "<provider> has empty authorities attribute";
+            return null;
+        }
         p.info.authority = cpname.intern();
 
         if (!parseProviderTags(res, parser, attrs, p, outError)) {
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 98096dc..f487f01 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -337,8 +337,7 @@
      * supported by a given camera device. This field lists the
      * valid anti-banding modes that the application may request
      * for this camera device with the
-     * {@link CaptureRequest#CONTROL_AE_ANTIBANDING_MODE android.control.aeAntibandingMode} control. This list
-     * always includes AUTO.</p>
+     * {@link CaptureRequest#CONTROL_AE_ANTIBANDING_MODE android.control.aeAntibandingMode} control.</p>
      * <p><b>Range of valid values:</b><br>
      * Any value listed in {@link CaptureRequest#CONTROL_AE_ANTIBANDING_MODE android.control.aeAntibandingMode}</p>
      * <p>This key is available on all devices.</p>
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 895ae04..999de8a 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -493,9 +493,11 @@
      * {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap}, the minimum frame
      * duration for that format and size is &lt;= 1/20 s, and
      * the {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES android.control.aeAvailableTargetFpsRanges} entry
-     * lists at least one FPS range where the minimum FPS
-     * is &gt;= 1 / minimumFrameDuration for the maximum-size
+     * lists at least one FPS range where the minimum FPS is</p>
+     * <blockquote>
+     * <p>= 1 / minimumFrameDuration for the maximum-size
      * YUV_420_888 format.</p>
+     * </blockquote>
      * <p>In addition, the {@link CameraCharacteristics#SYNC_MAX_LATENCY android.sync.maxLatency} field is
      * guaranted to have a value between 0 and 4, inclusive.</p>
      *
@@ -847,7 +849,8 @@
     /**
      * <p>The camera device will automatically adapt its
      * antibanding routine to the current illumination
-     * conditions. This is the default.</p>
+     * condition. This is the default mode if AUTO is
+     * available on given camera device.</p>
      * @see CaptureRequest#CONTROL_AE_ANTIBANDING_MODE
      */
     public static final int CONTROL_AE_ANTIBANDING_MODE_AUTO = 3;
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 48af67c..e89a402 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -642,8 +642,10 @@
      * options for the antibanding mode. The
      * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_ANTIBANDING_MODES android.control.aeAvailableAntibandingModes} key contains
      * the available modes for a given camera device.</p>
-     * <p>The default mode is AUTO, which is supported by all
-     * camera devices.</p>
+     * <p>AUTO mode is the default if it is available on given
+     * camera device. When AUTO mode is not available, the
+     * default will be either 50HZ or 60HZ, and both 50HZ
+     * and 60HZ will be available.</p>
      * <p>If manual exposure control is enabled (by setting
      * {@link CaptureRequest#CONTROL_AE_MODE android.control.aeMode} or {@link CaptureRequest#CONTROL_MODE android.control.mode} to OFF),
      * then this setting has no effect, and the application must
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index c5c843d..2c3b85f 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -493,8 +493,10 @@
      * options for the antibanding mode. The
      * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_ANTIBANDING_MODES android.control.aeAvailableAntibandingModes} key contains
      * the available modes for a given camera device.</p>
-     * <p>The default mode is AUTO, which is supported by all
-     * camera devices.</p>
+     * <p>AUTO mode is the default if it is available on given
+     * camera device. When AUTO mode is not available, the
+     * default will be either 50HZ or 60HZ, and both 50HZ
+     * and 60HZ will be available.</p>
      * <p>If manual exposure control is enabled (by setting
      * {@link CaptureRequest#CONTROL_AE_MODE android.control.aeMode} or {@link CaptureRequest#CONTROL_MODE android.control.mode} to OFF),
      * then this setting has no effect, and the application must
diff --git a/core/java/android/service/carrier/CarrierMessagingService.java b/core/java/android/service/carrier/CarrierMessagingService.java
new file mode 100644
index 0000000..3d6ebca
--- /dev/null
+++ b/core/java/android/service/carrier/CarrierMessagingService.java
@@ -0,0 +1,417 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.carrier;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SdkConstant;
+import android.app.Service;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.RemoteException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A service that receives calls from the system when new SMS and MMS are
+ * sent or received.
+ * <p>To extend this class, you must declare the service in your manifest file with
+ * the {@link android.Manifest.permission#BIND_CARRIER_MESSAGING_SERVICE} permission
+ * and include an intent filter with the {@link #SERVICE_INTERFACE} action. For example:</p>
+ * <pre>
+ * &lt;service android:name=".MyMessagingService"
+ *          android:label="&#64;string/service_name"
+ *          android:permission="android.permission.BIND_CARRIER_MESSAGING_SERVICE">
+ *     &lt;intent-filter>
+ *         &lt;action android:name="android.service.carrier.CarrierMessagingService" />
+ *     &lt;/intent-filter>
+ * &lt;/service></pre>
+ */
+public abstract class CarrierMessagingService extends Service {
+    /**
+     * The {@link android.content.Intent} that must be declared as handled by the service.
+     */
+    @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
+    public static final String SERVICE_INTERFACE
+            = "android.service.carrier.CarrierMessagingService";
+
+    /**
+     * Indicates that an SMS or MMS message was successfully sent.
+     */
+    public static final int SEND_STATUS_OK = 0;
+
+    /**
+     * SMS/MMS sending failed. We should retry via the carrier network.
+     */
+    public static final int SEND_STATUS_RETRY_ON_CARRIER_NETWORK = 1;
+
+    /**
+     * SMS/MMS sending failed. We should not retry via the carrier network.
+     */
+    public static final int SEND_STATUS_ERROR = 2;
+
+    /**
+     * Successfully downloaded an MMS message.
+     */
+    public static final int DOWNLOAD_STATUS_OK = 0;
+
+    /**
+     * MMS downloading failed. We should retry via the carrier network.
+     */
+    public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1;
+
+    /**
+     * MMS downloading failed. We should not retry via the carrier network.
+     */
+    public static final int DOWNLOAD_STATUS_ERROR = 2;
+
+    private final ICarrierMessagingWrapper mWrapper = new ICarrierMessagingWrapper();
+
+    /**
+     * Override this method to filter inbound SMS messages.
+     *
+     * @param pdu the PDUs of the message
+     * @param format the format of the PDUs, typically "3gpp" or "3gpp2"
+     * @param destPort the destination port of a binary SMS, this will be -1 for text SMS
+     * @param subId SMS subscription ID of the SIM
+     * @param callback result callback. Call with {@code true} to keep an inbound SMS message and
+     *        deliver to SMS apps, and {@code false} to drop the message.
+     */
+    public void onFilterSms(@NonNull MessagePdu pdu, @NonNull String format, int destPort,
+            int subId, @NonNull ResultCallback<Boolean> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(true);
+        } catch (RemoteException ex) {
+        }
+    }
+
+    /**
+     * Override this method to intercept text SMSs sent from the device.
+     *
+     * @param text the text to send
+     * @param subId SMS subscription ID of the SIM
+     * @param destAddress phone number of the recipient of the message
+     * @param callback result callback. Call with a {@link SendSmsResult}.
+     */
+    public void onSendTextSms(
+            @NonNull String text, int subId, @NonNull String destAddress,
+            @NonNull ResultCallback<SendSmsResult> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(new SendSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, 0));
+        } catch (RemoteException ex) {
+        }
+    }
+
+    /**
+     * Override this method to intercept binary SMSs sent from the device.
+     *
+     * @param data the binary content
+     * @param subId SMS subscription ID of the SIM
+     * @param destAddress phone number of the recipient of the message
+     * @param destPort the destination port
+     * @param callback result callback. Call with a {@link SendSmsResult}.
+     */
+    public void onSendDataSms(@NonNull byte[] data, int subId,
+            @NonNull String destAddress, int destPort,
+            @NonNull ResultCallback<SendSmsResult> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(new SendSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, 0));
+        } catch (RemoteException ex) {
+        }
+    }
+
+    /**
+     * Override this method to intercept long SMSs sent from the device.
+     *
+     * @param parts a {@link List} of the message parts
+     * @param subId SMS subscription ID of the SIM
+     * @param destAddress phone number of the recipient of the message
+     * @param callback result callback. Call with a {@link SendMultipartSmsResult}.
+     */
+    public void onSendMultipartTextSms(@NonNull List<String> parts,
+            int subId, @NonNull String destAddress,
+            @NonNull ResultCallback<SendMultipartSmsResult> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(
+                    new SendMultipartSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null));
+        } catch (RemoteException ex) {
+        }
+    }
+
+    /**
+     * Override this method to intercept MMSs sent from the device.
+     *
+     * @param pduUri the content provider URI of the PDU to send
+     * @param subId SMS subscription ID of the SIM
+     * @param location the optional URI to send this MMS PDU. If this is {code null},
+     *        the PDU should be sent to the default MMSC URL.
+     * @param callback result callback. Call with a {@link SendMmsResult}.
+     */
+    public void onSendMms(@NonNull Uri pduUri, int subId,
+            @Nullable Uri location, @NonNull ResultCallback<SendMmsResult> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(new SendMmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null));
+        } catch (RemoteException ex) {
+        }
+    }
+
+    /**
+     * Override this method to download MMSs received.
+     *
+     * @param contentUri the content provider URI of the PDU to be downloaded.
+     * @param subId SMS subscription ID of the SIM
+     * @param location the URI of the message to be downloaded.
+     * @param callback result callback. Call with a status code which is one of
+     *        {@link #DOWNLOAD_STATUS_OK},
+     *        {@link #DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK}, or {@link #DOWNLOAD_STATUS_ERROR}.
+     */
+    public void onDownloadMms(@NonNull Uri contentUri, int subId, @NonNull Uri location,
+            @NonNull ResultCallback<Integer> callback) {
+        // optional
+        try {
+            callback.onReceiveResult(DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK);
+        } catch (RemoteException ex) {
+        }
+    }
+
+    @Override
+    public @Nullable IBinder onBind(@NonNull Intent intent) {
+        if (!SERVICE_INTERFACE.equals(intent.getAction())) {
+            return null;
+        }
+        return mWrapper;
+    }
+
+    /**
+     * The result of sending an MMS.
+     */
+    public static final class SendMmsResult {
+        private int mSendStatus;
+        private byte[] mSendConfPdu;
+
+        /**
+         * Constructs a SendMmsResult with the MMS send result, and the SendConf PDU.
+         *
+         * @param sendStatus send status, one of {@link #SEND_STATUS_OK},
+         *        {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and
+         *        {@link #SEND_STATUS_ERROR}
+         * @param sendConfPdu a possibly {code null} SendConf PDU, which confirms that the message
+         *        was sent. sendConfPdu is ignored if the {@code result} is not
+         *        {@link #SEND_STATUS_OK}.
+         */
+        public SendMmsResult(int sendStatus, @Nullable byte[] sendConfPdu) {
+            mSendStatus = sendStatus;
+            mSendConfPdu = sendConfPdu;
+        }
+
+        /**
+         * Returns the send status of the just-sent MMS.
+         *
+         * @return the send status which is one of {@link #SEND_STATUS_OK},
+         *         {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and {@link #SEND_STATUS_ERROR}
+         */
+        public int getSendStatus() {
+            return mSendStatus;
+        }
+
+        /**
+         * Returns the SendConf PDU, which confirms that the message was sent.
+         *
+         * @return the SendConf PDU
+         */
+        public @Nullable byte[] getSendConfPdu() {
+            return mSendConfPdu;
+        }
+    }
+
+    /**
+     * The result of sending an SMS.
+     */
+    public static final class SendSmsResult {
+        private final int mSendStatus;
+        private final int mMessageRef;
+
+        /**
+         * Constructs a SendSmsResult with the send status and message reference for the
+         * just-sent SMS.
+         *
+         * @param sendStatus send status, one of {@link #SEND_STATUS_OK},
+         *        {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and {@link #SEND_STATUS_ERROR}.
+         * @param messageRef message reference of the just-sent SMS. This field is applicable only
+         *        if send status is {@link #SEND_STATUS_OK}.
+         */
+        public SendSmsResult(int sendStatus, int messageRef) {
+            mSendStatus = sendStatus;
+            mMessageRef = messageRef;
+        }
+
+        /**
+         * Returns the message reference of the just-sent SMS.
+         *
+         * @return the message reference
+         */
+        public int getMessageRef() {
+            return mMessageRef;
+        }
+
+        /**
+         * Returns the send status of the just-sent SMS.
+         *
+         * @return the send status
+         */
+        public int getSendStatus() {
+            return mSendStatus;
+        }
+    }
+
+    /**
+     * The result of sending a multipart SMS.
+     */
+    public static final class SendMultipartSmsResult {
+        private final int mSendStatus;
+        private final int[] mMessageRefs;
+
+        /**
+         * Constructs a SendMultipartSmsResult with the send status and message references for the
+         * just-sent multipart SMS.
+         *
+         * @param sendStatus send status, one of {@link #SEND_STATUS_OK},
+         *        {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and {@link #SEND_STATUS_ERROR}.
+         * @param messageRefs an array of message references, one for each part of the
+         *        multipart SMS. This field is applicable only if send status is
+         *        {@link #SEND_STATUS_OK}.
+         */
+        public SendMultipartSmsResult(int sendStatus, @Nullable int[] messageRefs) {
+            mSendStatus = sendStatus;
+            mMessageRefs = messageRefs;
+        }
+
+        /**
+         * Returns the message references of the just-sent multipart SMS.
+         *
+         * @return the message references, one for each part of the multipart SMS
+         */
+        public @Nullable int[] getMessageRefs() {
+            return mMessageRefs;
+        }
+
+        /**
+         * Returns the send status of the just-sent SMS.
+         *
+         * @return the send status
+         */
+        public int getSendStatus() {
+            return mSendStatus;
+        }
+    }
+
+    /**
+     * A callback interface used to provide results asynchronously.
+     */
+    public interface ResultCallback<T> {
+        /**
+         * Invoked when the result is available.
+         *
+         * @param result the result
+         */
+        public void onReceiveResult(@NonNull T result) throws RemoteException;
+    };
+
+    /**
+     * A wrapper around ICarrierMessagingService to enable the carrier messaging app to implement
+     * methods it cares about in the {@link ICarrierMessagingService} interface.
+     */
+    private class ICarrierMessagingWrapper extends ICarrierMessagingService.Stub {
+        @Override
+        public void filterSms(MessagePdu pdu, String format, int destPort,
+                              int subId, final ICarrierMessagingCallback callback) {
+            onFilterSms(pdu, format, destPort, subId, new ResultCallback<Boolean>() {
+                    @Override
+                    public void onReceiveResult(final Boolean result) throws RemoteException {
+                        callback.onFilterComplete(result);
+                    }
+                });
+        }
+
+        @Override
+        public void sendTextSms(String text, int subId, String destAddress,
+                                final ICarrierMessagingCallback callback) {
+            onSendTextSms(text, subId, destAddress, new ResultCallback<SendSmsResult>() {
+                    @Override
+                    public void onReceiveResult(final SendSmsResult result) throws RemoteException {
+                        callback.onSendSmsComplete(result.getSendStatus(), result.getMessageRef());
+                    }
+                });
+        }
+
+        @Override
+        public void sendDataSms(byte[] data, int subId, String destAddress, int destPort,
+                                final ICarrierMessagingCallback callback) {
+            onSendDataSms(data, subId, destAddress, destPort, new ResultCallback<SendSmsResult>() {
+                    @Override
+                    public void onReceiveResult(final SendSmsResult result) throws RemoteException {
+                        callback.onSendSmsComplete(result.getSendStatus(), result.getMessageRef());
+                    }
+                });
+        }
+
+        @Override
+        public void sendMultipartTextSms(List<String> parts, int subId, String destAddress,
+                                         final ICarrierMessagingCallback callback) {
+                onSendMultipartTextSms(parts, subId, destAddress,
+                        new ResultCallback<SendMultipartSmsResult>() {
+                                @Override
+                                public void onReceiveResult(final SendMultipartSmsResult result)
+                                        throws RemoteException {
+                                    callback.onSendMultipartSmsComplete(
+                                            result.getSendStatus(), result.getMessageRefs());
+                                }
+                            });
+        }
+
+        @Override
+        public void sendMms(Uri pduUri, int subId, Uri location,
+                final ICarrierMessagingCallback callback) {
+            onSendMms(pduUri, subId, location, new ResultCallback<SendMmsResult>() {
+                    @Override
+                    public void onReceiveResult(final SendMmsResult result) throws RemoteException {
+                        callback.onSendMmsComplete(result.getSendStatus(), result.getSendConfPdu());
+                    }
+                });
+        }
+
+        @Override
+        public void downloadMms(Uri pduUri, int subId, Uri location,
+                final ICarrierMessagingCallback callback) {
+            onDownloadMms(pduUri, subId, location, new ResultCallback<Integer>() {
+                    @Override
+                    public void onReceiveResult(Integer result) throws RemoteException {
+                        callback.onDownloadMmsComplete(result);
+                    }
+                });
+        }
+    }
+}
diff --git a/core/java/android/service/carriermessaging/ICarrierMessagingCallback.aidl b/core/java/android/service/carrier/ICarrierMessagingCallback.aidl
similarity index 73%
rename from core/java/android/service/carriermessaging/ICarrierMessagingCallback.aidl
rename to core/java/android/service/carrier/ICarrierMessagingCallback.aidl
index da56ad1..6118a20 100644
--- a/core/java/android/service/carriermessaging/ICarrierMessagingCallback.aidl
+++ b/core/java/android/service/carrier/ICarrierMessagingCallback.aidl
@@ -14,20 +14,17 @@
  * limitations under the License.
  */
 
-package android.service.carriermessaging;
-
-import android.service.carriermessaging.CarrierMessagingService;
+package android.service.carrier;
 
 /**
  * Callback interface definition for the Carrier Messaging Service client to get informed of the
  * result of various API invocations.
+ * @hide
  */
 oneway interface ICarrierMessagingCallback {
     void onFilterComplete(boolean keepMessage);
-    void onSendSmsComplete(
-        int result, in CarrierMessagingService.SendSmsResponse sendSmsResponse);
-    void onSendMultipartSmsComplete(
-        int result, in List<CarrierMessagingService.SendSmsResponse> sendSmsResponses);
+    void onSendSmsComplete(int result, int messageRef);
+    void onSendMultipartSmsComplete(int result, in int[] messageRefs);
     void onSendMmsComplete(int result, in byte[] sendConfPdu);
     void onDownloadMmsComplete(int result);
 }
diff --git a/core/java/android/service/carriermessaging/ICarrierMessagingService.aidl b/core/java/android/service/carrier/ICarrierMessagingService.aidl
similarity index 72%
rename from core/java/android/service/carriermessaging/ICarrierMessagingService.aidl
rename to core/java/android/service/carrier/ICarrierMessagingService.aidl
index 6e9e3fa..40a9047 100644
--- a/core/java/android/service/carriermessaging/ICarrierMessagingService.aidl
+++ b/core/java/android/service/carrier/ICarrierMessagingService.aidl
@@ -14,15 +14,16 @@
  * limitations under the License.
  */
 
-package android.service.carriermessaging;
+package android.service.carrier;
 
 import android.net.Uri;
-import android.service.carriermessaging.ICarrierMessagingCallback;
-import android.service.carriermessaging.MessagePdu;
+import android.service.carrier.ICarrierMessagingCallback;
+import android.service.carrier.MessagePdu;
 
 /**
  * <p class="note"><strong>Note:</strong>
  * This service can only be implemented by a carrier privileged app.
+ * @hide
  */
 oneway interface ICarrierMessagingService {
     /**
@@ -32,10 +33,12 @@
      * @param pdu the PDUs of the message
      * @param format the format of the PDUs, typically "3gpp" or "3gpp2"
      * @param destPort the destination port of a data SMS. It will be -1 for text SMS
+     * @param subId SMS subscription ID of the SIM
      * @param callback the callback to notify upon completion
      */
     void filterSms(
-        in MessagePdu pdu, String format, int destPort, in ICarrierMessagingCallback callback);
+        in MessagePdu pdu, String format, int destPort, int subId,
+        in ICarrierMessagingCallback callback);
 
     /**
      * Request sending a new text SMS from the device.
@@ -43,11 +46,11 @@
      * status.
      *
      * @param text the text to send
-     * @param format the format of the response PDU, typically "3gpp" or "3gpp2"
+     * @param subId SMS subscription ID of the SIM
      * @param destAddress phone number of the recipient of the message
      * @param callback the callback to notify upon completion
      */
-    void sendTextSms(String text, String format, String destAddress,
+    void sendTextSms(String text, int subId, String destAddress,
             in ICarrierMessagingCallback callback);
 
     /**
@@ -56,12 +59,12 @@
      * status.
      *
      * @param data the data to send
-     * @param format the format of the response PDU, typically "3gpp" or "3gpp2"
+     * @param subId SMS subscription ID of the SIM
      * @param destAddress phone number of the recipient of the message
      * @param destPort port number of the recipient of the message
      * @param callback the callback to notify upon completion
      */
-    void sendDataSms(in byte[] data, String format, String destAddress, int destPort,
+    void sendDataSms(in byte[] data, int subId, String destAddress, int destPort,
             in ICarrierMessagingCallback callback);
 
     /**
@@ -70,11 +73,11 @@
      * with the send status.
      *
      * @param parts the parts of the multi-part text SMS to send
-     * @param format the format of the response PDU, typically "3gpp" or "3gpp2"
+     * @param subId SMS subscription ID of the SIM
      * @param destAddress phone number of the recipient of the message
      * @param callback the callback to notify upon completion
      */
-    void sendMultipartTextSms(in List<String> parts, String format, String destAddress,
+    void sendMultipartTextSms(in List<String> parts, int subId, String destAddress,
             in ICarrierMessagingCallback callback);
 
     /**
@@ -83,11 +86,13 @@
      * status.
      *
      * @param pduUri the content provider URI of the PDU to send
-     * @param locationUrl the optional url to send this MMS PDU.
-     *         If this is not specified, PDU should be sent to the default MMSC url.
+     * @param subId SMS subscription ID of the SIM
+     * @param location the optional URI to send this MMS PDU. If this is {code null},
+     *        the PDU should be sent to the default MMSC URL.
      * @param callback the callback to notify upon completion
      */
-    void sendMms(in Uri pduUri, String locationUrl, in ICarrierMessagingCallback callback);
+    void sendMms(in Uri pduUri, int subId, in Uri location,
+            in ICarrierMessagingCallback callback);
 
     /**
      * Request downloading a new MMS.
@@ -95,9 +100,11 @@
      * download status.
      *
      * @param pduUri the content provider URI of the PDU to be downloaded.
-     * @param locationUrl the URL of the message to be downloaded.
+     * @param subId SMS subscription ID of the SIM
+     * @param location the URI of the message to be downloaded.
      * @param callback the callback to notify upon completion
      */
-    void downloadMms(in Uri pduUri, String locationUrl, in ICarrierMessagingCallback callback);
+    void downloadMms(in Uri pduUri, int subId, in Uri location,
+            in ICarrierMessagingCallback callback);
 }
 
diff --git a/core/java/android/service/carriermessaging/MessagePdu.aidl b/core/java/android/service/carrier/MessagePdu.aidl
similarity index 93%
rename from core/java/android/service/carriermessaging/MessagePdu.aidl
rename to core/java/android/service/carrier/MessagePdu.aidl
index 82b3fb3..f0528a5 100644
--- a/core/java/android/service/carriermessaging/MessagePdu.aidl
+++ b/core/java/android/service/carrier/MessagePdu.aidl
@@ -14,6 +14,6 @@
  * limitations under the License.
  */
 
-package android.service.carriermessaging;
+package android.service.carrier;
 
-parcelable MessagePdu;
\ No newline at end of file
+parcelable MessagePdu;
diff --git a/core/java/android/service/carriermessaging/MessagePdu.java b/core/java/android/service/carrier/MessagePdu.java
similarity index 98%
rename from core/java/android/service/carriermessaging/MessagePdu.java
rename to core/java/android/service/carrier/MessagePdu.java
index 3c78568..ca18e53 100644
--- a/core/java/android/service/carriermessaging/MessagePdu.java
+++ b/core/java/android/service/carrier/MessagePdu.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.service.carriermessaging;
+package android.service.carrier;
 
 import android.annotation.NonNull;
 import android.os.Parcel;
diff --git a/core/java/android/service/carriermessaging/CarrierMessagingService.aidl b/core/java/android/service/carriermessaging/CarrierMessagingService.aidl
deleted file mode 100644
index 50c438a..0000000
--- a/core/java/android/service/carriermessaging/CarrierMessagingService.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.service.carriermessaging;
-
-parcelable CarrierMessagingService.SendSmsResponse;
\ No newline at end of file
diff --git a/core/java/android/service/carriermessaging/CarrierMessagingService.java b/core/java/android/service/carriermessaging/CarrierMessagingService.java
deleted file mode 100644
index 7aea590..0000000
--- a/core/java/android/service/carriermessaging/CarrierMessagingService.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.service.carriermessaging;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.annotation.SdkConstant;
-import android.app.Service;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.RemoteException;
-
-import java.util.List;
-
-/**
- * A service that receives calls from the system when new SMS and MMS are
- * sent or received.
- * <p>To extend this class, you must declare the service in your manifest file with
- * the {@link android.Manifest.permission#BIND_CARRIER_MESSAGING_SERVICE} permission
- * and include an intent filter with the {@link #SERVICE_INTERFACE} action. For example:</p>
- * <pre>
- * &lt;service android:name=".MyMessagingService"
- *          android:label="&#64;string/service_name"
- *          android:permission="android.permission.BIND_CARRIER_MESSAGING_SERVICE">
- *     &lt;intent-filter>
- *         &lt;action android:name="android.service.carriermessaging.CarrierMessagingService" />
- *     &lt;/intent-filter>
- * &lt;/service></pre>
- */
-public abstract class CarrierMessagingService extends Service {
-    /**
-     * The {@link android.content.Intent} that must be declared as handled by the service.
-     */
-    @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
-    public static final String SERVICE_INTERFACE
-            = "android.service.carriermessaging.CarrierMessagingService";
-
-    /**
-     * Indicates that an SMS or MMS message was successfully sent.
-     */
-    public static final int SEND_STATUS_OK = 0;
-
-    /**
-     * SMS/MMS sending failed. We should retry via the carrier network.
-     */
-    public static final int SEND_STATUS_RETRY_ON_CARRIER_NETWORK = 1;
-
-    /**
-     * SMS/MMS sending failed. We should not retry via the carrier network.
-     */
-    public static final int SEND_STATUS_ERROR = 2;
-
-    /**
-     * Successfully downloaded an MMS message.
-     */
-    public static final int DOWNLOAD_STATUS_OK = 0;
-
-    /**
-     * MMS downloading failed. We should retry via the carrier network.
-     */
-    public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK = 1;
-
-    /**
-     * MMS downloading failed. We should not retry via the carrier network.
-     */
-    public static final int DOWNLOAD_STATUS_ERROR = 2;
-
-    private final ICarrierMessagingWrapper mWrapper = new ICarrierMessagingWrapper();
-
-    /**
-     * Implement this method to filter SMS messages.
-     *
-     * @param pdu the PDUs of the message
-     * @param format the format of the PDUs, typically "3gpp" or "3gpp2"
-     * @param destPort the destination port of a binary SMS, this will be -1 for text SMS
-     *
-     * @return True to keep an inbound SMS message and delivered to SMS apps. False to
-     * drop the message.
-     */
-    public boolean onFilterSms(@NonNull MessagePdu pdu, @NonNull String format, int destPort) {
-        // optional
-        return true;
-    }
-
-    /**
-     * Implement this method to intercept text SMSs sent from the devcie.
-     *
-     * @param text the text to send
-     * @param format the format of the response PDU, typically "3gpp" or "3gpp2"
-     * @param destAddress phone number of the recipient of the message
-     *
-     * @return a possibly {code null} {@link SendSmsResponse}. Upon returning {@code null}, the SMS
-     *         is sent using the carrier network.
-     */
-    public @Nullable SendSmsResponse onSendTextSms(
-            @NonNull String text, @NonNull String format, @NonNull String destAddress) {
-        // optional
-        return null;
-    }
-
-    /**
-     * Implement this method to intercept binary SMSs sent from the device.
-     *
-     * @param data the binary content
-     * @param format format the format of the response PDU, typically "3gpp" or "3gpp2"
-     * @param destAddress phone number of the recipient of the message
-     * @param destPort the destination port
-     *
-     * @return a possibly {code null} {@link SendSmsResponse}. Upon returning {@code null}, the SMS
-     *         is sent using the carrier network.
-     */
-    public @Nullable SendSmsResponse onSendDataSms(@NonNull byte[] data, @NonNull String format,
-            @NonNull String destAddress, int destPort) {
-        // optional
-        return null;
-    }
-
-    /**
-     * Implement this method to intercept long SMSs sent from the device.
-     *
-     * @param parts a {@link List} of the message parts
-     * @param format format the format of the response PDU, typically "3gpp" or "3gpp2"
-     * @param destAddress phone number of the recipient of the message
-     *
-     * @return a possibly {code null} {@link List} of {@link SendSmsResponse}, one for each message
-     *         part. Upon returning {@code null}, the SMS is sent using the carrier network.
-     */
-    public @Nullable List<SendSmsResponse> onSendMultipartTextSms(@NonNull List<String> parts,
-            @NonNull String format, @NonNull String destAddress) {
-        // optional
-        return null;
-    }
-
-    /**
-     * Implement this method to intercept MMSs sent from the device.
-     *
-     * @param pduUri the content provider URI of the PDU to send
-     * @param locationUrl the optional URL to send this MMS PDU. If this is not specified,
-     *                    the PDU should be sent to the default MMSC URL.
-     *
-     * @return a possibly {@code null} {@link SendMmsResult}. Upon returning {@code null}, the
-     *         MMS is sent using the carrier network.
-     */
-    public @Nullable SendMmsResult onSendMms(@NonNull Uri pduUri, @Nullable String locationUrl) {
-        // optional
-        return null;
-    }
-
-    /**
-     * Implement this method to download MMSs received.
-     *
-     * @param contentUri the content provider URI of the PDU to be downloaded.
-     * @param locationUrl the URL of the message to be downloaded.
-     *
-     * @return a {@link SendMmsResult}.
-     */
-    public int onDownloadMms(@NonNull Uri contentUri, @NonNull String locationUrl) {
-        // optional
-        return DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK;
-    }
-
-    @Override
-    public @Nullable IBinder onBind(@NonNull Intent intent) {
-        if (!SERVICE_INTERFACE.equals(intent.getAction())) {
-            return null;
-        }
-        return mWrapper;
-    }
-
-    /**
-     * The result of sending an MMS.
-     */
-    public static final class SendMmsResult {
-        private int mResult;
-        private byte[] mSendConfPdu;
-
-        /**
-         * Constructs a SendMmsResult with the MMS send result, and the SenConf PDU.
-         *
-         * @param result the result which is one of {@link #SEND_STATUS_OK},
-         *               {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and
-         *               {@link #SEND_STATUS_ERROR}
-         * @param sendConfPdu a possibly {code null} SendConf PDU, which confirms that the message
-         *        was sent. sendConfPdu is ignored if the {@code result} is not
-         *        {@link #SEND_STATUS_OK}
-         */
-        public SendMmsResult(int result, @Nullable byte[] sendConfPdu) {
-            mResult = result;
-            mSendConfPdu = sendConfPdu;
-        }
-
-        /**
-         * Returns the result of sending the MMS.
-         *
-         * @return the result which is one of {@link #SEND_STATUS_OK},
-         *         {@link #SEND_STATUS_RETRY_ON_CARRIER_NETWORK}, and {@link #SEND_STATUS_ERROR}
-         */
-        public int getResult() {
-            return mResult;
-        }
-
-        /**
-         * Returns the SendConf PDU, which confirms that the message was sent.
-         *
-         * @return the SendConf PDU
-         */
-        public @Nullable byte[] getSendConfPdu() {
-            return mSendConfPdu;
-        }
-    }
-
-    /**
-     * Object passed in callbacks upon successful completion of
-     * {@link ICarrierMessagingService#sendTextSms},
-     * {@link ICarrierMessagingService#sendDataSms}, and
-     * {@link ICarrierMessagingService#sendMultipartTextSms}.
-     * Contains message reference and ackPdu.
-     */
-    public static final class SendSmsResponse implements Parcelable {
-        private int mMessageRef;
-        private byte[] mAckPdu;
-        private int mErrorCode;
-
-        /**
-         * Constructs a SendSmsResponse for the message reference, the ack PDU, and error code for
-         * the just-sent SMS.
-         *
-         * @param messageRef message reference of the just-sent SMS
-         * @param ackPdu ackPdu for the just-sent SMS
-         * @param errorCode error code. See 3GPP 27.005, 3.2.5 for GSM/UMTS,
-         *     3GPP2 N.S0005 (IS-41C) Table 171 for CDMA, -1 if unknown or not applicable.
-         */
-        public SendSmsResponse(int messageRef, @NonNull byte[] ackPdu, int errorCode) {
-            mMessageRef = messageRef;
-            mAckPdu = ackPdu;
-            mErrorCode = errorCode;
-        }
-
-        /**
-         * Returns the message reference of the just-sent SMS.
-         *
-         * @return the message reference
-         */
-        public int getMessageRef() {
-            return mMessageRef;
-        }
-
-        /**
-         * Returns the ackPdu for the just-sent SMS.
-         *
-         * @return the ackPdu
-         */
-        public @NonNull byte[] getAckPdu() {
-            return mAckPdu;
-        }
-
-        /**
-         * Returns the error code upon encountering an error while sending the SMS, -1 if unknown or
-         * not applicable.
-         *
-         * @return errorCode the errorCode as defined in 3GPP 27.005, 3.2.5 for GSM/UMTS, and 3GPP2
-         * N.S0005 (IS-41C) Table 171 for CDMA, -1 if unknown or not applicable.
-         */
-        public int getErrorCode() {
-            return mErrorCode;
-        }
-
-        @Override
-        public int describeContents() {
-            return 0;
-        }
-
-        @Override
-        public void writeToParcel(Parcel dest, int flags) {
-            dest.writeInt(mMessageRef);
-            dest.writeByteArray(mAckPdu);
-            dest.writeInt(mErrorCode);
-        }
-
-        public static final Parcelable.Creator<SendSmsResponse> CREATOR
-                = new Parcelable.Creator<SendSmsResponse>() {
-                    @Override
-                    public SendSmsResponse createFromParcel(Parcel source) {
-                        return new SendSmsResponse(source.readInt(),
-                                                   source.createByteArray(),
-                                                   source.readInt());
-                    }
-
-                    @Override
-                    public SendSmsResponse[] newArray(int size) {
-                        return new SendSmsResponse[size];
-                    }
-        };
-    }
-
-    /**
-     * A wrapper around ICarrierMessagingService to enable the carrier messaging APP to implement
-     * methods it cares about in the {@link ICarrierMessagingService} interface.
-     */
-    private class ICarrierMessagingWrapper extends ICarrierMessagingService.Stub {
-        @Override
-        public void filterSms(MessagePdu pdu, String format, int destPort,
-                              ICarrierMessagingCallback callback) {
-            try {
-                callback.onFilterComplete(onFilterSms(pdu, format, destPort));
-            } catch (RemoteException ex) {
-            }
-        }
-
-        @Override
-        public void sendTextSms(String text, String format, String destAddress,
-                                ICarrierMessagingCallback callback) {
-            try {
-                SendSmsResponse sendSmsResponse = onSendTextSms(text, format, destAddress);
-                if (sendSmsResponse == null) {
-                    callback.onSendSmsComplete(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null);
-                } else {
-                    callback.onSendSmsComplete(SEND_STATUS_OK, sendSmsResponse);
-                }
-            } catch (RemoteException ex) {
-            }
-        }
-
-        @Override
-        public void sendDataSms(byte[] data, String format, String destAddress, int destPort,
-                                ICarrierMessagingCallback callback) {
-            try {
-                SendSmsResponse sendSmsResponse = onSendDataSms(data, format, destAddress,
-                        destPort);
-                if (sendSmsResponse == null) {
-                    callback.onSendSmsComplete(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null);
-                } else {
-                    callback.onSendSmsComplete(SEND_STATUS_OK, sendSmsResponse);
-                }
-            } catch (RemoteException ex) {
-            }
-        }
-
-        @Override
-        public void sendMultipartTextSms(List<String> parts, String format, String destAddress,
-                                         ICarrierMessagingCallback callback) {
-            try {
-                List<SendSmsResponse> sendSmsResponses =
-                        onSendMultipartTextSms(parts, format, destAddress);
-                if (sendSmsResponses == null) {
-                    callback.onSendMultipartSmsComplete(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null);
-                } else {
-                    callback.onSendMultipartSmsComplete(SEND_STATUS_OK, sendSmsResponses);
-                }
-            } catch (RemoteException ex) {
-            }
-        }
-
-        @Override
-        public void sendMms(Uri pduUri, String locationUrl, ICarrierMessagingCallback callback) {
-            try {
-                SendMmsResult result = onSendMms(pduUri, locationUrl);
-                if (result == null) {
-                    callback.onSendMmsComplete(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null);
-                } else {
-                    callback.onSendMmsComplete(SEND_STATUS_OK, result.getSendConfPdu());
-                }
-            } catch (RemoteException ex) {
-            }
-        }
-
-        @Override
-        public void downloadMms(Uri contentUri, String locationUrl,
-                ICarrierMessagingCallback callback) {
-            try {
-                callback.onDownloadMmsComplete(onDownloadMms(contentUri, locationUrl));
-            } catch (RemoteException ex) {
-            }
-        }
-    }
-}
diff --git a/core/java/android/service/carriermessaging/CarrierMessagingServiceManager.java b/core/java/android/service/carriermessaging/CarrierMessagingServiceManager.java
deleted file mode 100644
index 56ee2c1..0000000
--- a/core/java/android/service/carriermessaging/CarrierMessagingServiceManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.service.carriermessaging;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-
-import com.android.internal.util.Preconditions;
-
-/**
- * Provides basic structure for platform to connect to the carrier messaging service.
- * <p>
- * <code>
- * CarrierMessagingServiceManager carrierMessagingServiceManager =
- *     new CarrierMessagingServiceManagerImpl();
- * if (carrierMessagingServiceManager.bindToCarrierMessagingService(context, carrierPackageName)) {
- *   // wait for onServiceReady callback
- * } else {
- *   // Unable to bind: handle error.
- * }
- * </code>
- * <p> Upon completion {@link #disposeConnection} should be called to unbind the
- * CarrierMessagingService.
- * @hide
- */
-public abstract class CarrierMessagingServiceManager {
-    // Populated by bindToCarrierMessagingService. bindToCarrierMessagingService must complete
-    // prior to calling disposeConnection so that mCarrierMessagingServiceConnection is initialized.
-    private volatile CarrierMessagingServiceConnection mCarrierMessagingServiceConnection;
-
-    /**
-     * Binds to the carrier messaging service under package {@code carrierPackageName}. This method
-     * should be called exactly once.
-     *
-     * @param context the context
-     * @param carrierPackageName the carrier package name
-     * @return true upon successfully binding to a carrier messaging service, false otherwise
-     */
-    public boolean bindToCarrierMessagingService(Context context, String carrierPackageName) {
-        Preconditions.checkState(mCarrierMessagingServiceConnection == null);
-
-        Intent intent = new Intent(CarrierMessagingService.SERVICE_INTERFACE);
-        intent.setPackage(carrierPackageName);
-        mCarrierMessagingServiceConnection = new CarrierMessagingServiceConnection();
-        return context.bindService(intent, mCarrierMessagingServiceConnection,
-                Context.BIND_AUTO_CREATE);
-    }
-
-    /**
-     * Unbinds the carrier messaging service. This method should be called exactly once.
-     *
-     * @param context the context
-     */
-    public void disposeConnection(Context context) {
-        Preconditions.checkNotNull(mCarrierMessagingServiceConnection);
-        context.unbindService(mCarrierMessagingServiceConnection);
-        mCarrierMessagingServiceConnection = null;
-    }
-
-    /**
-     * Implemented by subclasses to use the carrier messaging service once it is ready.
-     *
-     * @param carrierMessagingService the carirer messaing service interface
-     */
-    protected abstract void onServiceReady(ICarrierMessagingService carrierMessagingService);
-
-    /**
-     * A basic {@link ServiceConnection}.
-     */
-    private final class CarrierMessagingServiceConnection implements ServiceConnection {
-        @Override
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            onServiceReady(ICarrierMessagingService.Stub.asInterface(service));
-        }
-
-        @Override
-        public void onServiceDisconnected(ComponentName name) {
-        }
-    }
-}
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 904e33f..c5c3f83 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -235,7 +235,7 @@
      * or not the surface used by the HardwareRenderer will be changing. It
      * Suspends any rendering into the surface, but will not do any destruction
      */
-    abstract void pauseSurface(Surface surface);
+    abstract boolean pauseSurface(Surface surface);
 
     /**
      * Destroys all hardware rendering resources associated with the specified
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 131c039..14b950f 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -155,8 +155,8 @@
     }
 
     @Override
-    void pauseSurface(Surface surface) {
-        nPauseSurface(mNativeProxy, surface);
+    boolean pauseSurface(Surface surface) {
+        return nPauseSurface(mNativeProxy, surface);
     }
 
     @Override
@@ -494,7 +494,7 @@
 
     private static native boolean nInitialize(long nativeProxy, Surface window);
     private static native void nUpdateSurface(long nativeProxy, Surface window);
-    private static native void nPauseSurface(long nativeProxy, Surface window);
+    private static native boolean nPauseSurface(long nativeProxy, Surface window);
     private static native void nSetup(long nativeProxy, int width, int height,
             float lightX, float lightY, float lightZ, float lightRadius,
             int ambientShadowAlpha, int spotShadowAlpha);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index b12c747..34c27d7 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1493,7 +1493,11 @@
                     // relayoutWindow may decide to destroy mSurface. As that decision
                     // happens in WindowManager service, we need to be defensive here
                     // and stop using the surface in case it gets destroyed.
-                    mAttachInfo.mHardwareRenderer.pauseSurface(mSurface);
+                    if (mAttachInfo.mHardwareRenderer.pauseSurface(mSurface)) {
+                        // Animations were running so we need to push a frame
+                        // to resume them
+                        mDirty.set(0, 0, mWidth, mHeight);
+                    }
                 }
                 final int surfaceGenerationId = mSurface.getGenerationId();
                 relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index 6219956..b9d849c 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -270,14 +270,14 @@
     proxy->updateSurface(window);
 }
 
-static void android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject clazz,
+static jboolean android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject clazz,
         jlong proxyPtr, jobject jsurface) {
     RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
     sp<ANativeWindow> window;
     if (jsurface) {
         window = android_view_Surface_getNativeWindow(env, jsurface);
     }
-    proxy->pauseSurface(window);
+    return proxy->pauseSurface(window);
 }
 
 static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
@@ -429,7 +429,7 @@
     { "nLoadSystemProperties", "(J)Z", (void*) android_view_ThreadedRenderer_loadSystemProperties },
     { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize },
     { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
-    { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface },
+    { "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
     { "nSetup", "(JIIFFFFII)V", (void*) android_view_ThreadedRenderer_setup },
     { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
     { "nSyncAndDrawFrame", "(JJJF)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index dec7f07..3dd9770 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2910,7 +2910,7 @@
         android:description="@string/permdesc_removeDrmCertificates"
         android:protectionLevel="signature|system" />
 
-    <!-- Must be required by a {@link android.service.carriermessaging.CarrierMessagingService}.
+    <!-- Must be required by a {@link android.service.carrier.CarrierMessagingService}.
          Any service that filters for this intent must be a carrier privileged app. -->
     <permission android:name="android.permission.BIND_CARRIER_MESSAGING_SERVICE"
         android:label="@string/permlab_bindCarrierMessagingService"
diff --git a/core/res/res/values-mcc310-mnc120/config.xml b/core/res/res/values-mcc310-mnc120/config.xml
index 774732d..4b61688 100644
--- a/core/res/res/values-mcc310-mnc120/config.xml
+++ b/core/res/res/values-mcc310-mnc120/config.xml
@@ -31,4 +31,31 @@
     <!-- If this value is true, The mms content-disposition field is supported correctly.
          If false, Content-disposition fragments are ignored -->
     <bool name="config_mms_content_disposition_support">false</bool>
+
+    <!-- An array of CDMA roaming indicators which means international roaming -->
+    <integer-array translatable="false" name="config_cdma_international_roaming_indicators" >
+        <item>2</item>
+        <item>74</item>
+        <item>124</item>
+        <item>125</item>
+        <item>126</item>
+        <item>157</item>
+        <item>158</item>
+        <item>159</item>
+        <item>193</item>
+        <item>194</item>
+        <item>195</item>
+        <item>196</item>
+        <item>197</item>
+        <item>198</item>
+        <item>228</item>
+        <item>229</item>
+        <item>230</item>
+        <item>231</item>
+        <item>232</item>
+        <item>233</item>
+        <item>234</item>
+        <item>235</item>
+    </integer-array>
+
 </resources>
diff --git a/core/res/res/values-mcc311-mnc490/config.xml b/core/res/res/values-mcc311-mnc490/config.xml
index defe78d..d481c97 100644
--- a/core/res/res/values-mcc311-mnc490/config.xml
+++ b/core/res/res/values-mcc311-mnc490/config.xml
@@ -23,4 +23,31 @@
 
     <!-- Sprint need a 70 ms delay for 3way call -->
     <integer name="config_cdma_3waycall_flash_delay">70</integer>
+
+    <!-- An array of CDMA roaming indicators which means international roaming -->
+    <integer-array translatable="false" name="config_cdma_international_roaming_indicators" >
+        <item>2</item>
+        <item>74</item>
+        <item>124</item>
+        <item>125</item>
+        <item>126</item>
+        <item>157</item>
+        <item>158</item>
+        <item>159</item>
+        <item>193</item>
+        <item>194</item>
+        <item>195</item>
+        <item>196</item>
+        <item>197</item>
+        <item>198</item>
+        <item>228</item>
+        <item>229</item>
+        <item>230</item>
+        <item>231</item>
+        <item>232</item>
+        <item>233</item>
+        <item>234</item>
+        <item>235</item>
+    </integer-array>
+
 </resources>
diff --git a/core/res/res/values-mcc311-mnc870/config.xml b/core/res/res/values-mcc311-mnc870/config.xml
index 24e55b1..98cb72e 100644
--- a/core/res/res/values-mcc311-mnc870/config.xml
+++ b/core/res/res/values-mcc311-mnc870/config.xml
@@ -27,4 +27,31 @@
 
     <!-- Sprint need a 70 ms delay for 3way call -->
     <integer name="config_cdma_3waycall_flash_delay">70</integer>
+
+    <!-- An array of CDMA roaming indicators which means international roaming -->
+    <integer-array translatable="false" name="config_cdma_international_roaming_indicators" >
+        <item>2</item>
+        <item>74</item>
+        <item>124</item>
+        <item>125</item>
+        <item>126</item>
+        <item>157</item>
+        <item>158</item>
+        <item>159</item>
+        <item>193</item>
+        <item>194</item>
+        <item>195</item>
+        <item>196</item>
+        <item>197</item>
+        <item>198</item>
+        <item>228</item>
+        <item>229</item>
+        <item>230</item>
+        <item>231</item>
+        <item>232</item>
+        <item>233</item>
+        <item>234</item>
+        <item>235</item>
+    </integer-array>
+
 </resources>
diff --git a/core/res/res/values-mcc312-mnc530/config.xml b/core/res/res/values-mcc312-mnc530/config.xml
index 24e55b1..98cb72e 100644
--- a/core/res/res/values-mcc312-mnc530/config.xml
+++ b/core/res/res/values-mcc312-mnc530/config.xml
@@ -27,4 +27,31 @@
 
     <!-- Sprint need a 70 ms delay for 3way call -->
     <integer name="config_cdma_3waycall_flash_delay">70</integer>
+
+    <!-- An array of CDMA roaming indicators which means international roaming -->
+    <integer-array translatable="false" name="config_cdma_international_roaming_indicators" >
+        <item>2</item>
+        <item>74</item>
+        <item>124</item>
+        <item>125</item>
+        <item>126</item>
+        <item>157</item>
+        <item>158</item>
+        <item>159</item>
+        <item>193</item>
+        <item>194</item>
+        <item>195</item>
+        <item>196</item>
+        <item>197</item>
+        <item>198</item>
+        <item>228</item>
+        <item>229</item>
+        <item>230</item>
+        <item>231</item>
+        <item>232</item>
+        <item>233</item>
+        <item>234</item>
+        <item>235</item>
+    </integer-array>
+
 </resources>
diff --git a/core/res/res/values-mcc415-mnc01/config.xml b/core/res/res/values-mcc415-mnc01/config.xml
new file mode 100644
index 0000000..95d30a4
--- /dev/null
+++ b/core/res/res/values-mcc415-mnc01/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+    <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values-mcc416-mnc77/config.xml b/core/res/res/values-mcc416-mnc77/config.xml
new file mode 100644
index 0000000..95d30a4
--- /dev/null
+++ b/core/res/res/values-mcc416-mnc77/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+    <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values-mcc432-mnc20/config.xml b/core/res/res/values-mcc432-mnc20/config.xml
new file mode 100644
index 0000000..95d30a4
--- /dev/null
+++ b/core/res/res/values-mcc432-mnc20/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+    <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index cdbee61..926b53e 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1952,4 +1952,11 @@
     <dimen name="config_mediaMetadataBitmapMaxSize">320dp</dimen>
 
     <string translatable="false" name="prohibit_manual_network_selection_in_gobal_mode">false</string>
+
+    <!-- An array of CDMA roaming indicators which means international roaming -->
+    <integer-array translatable="false" name="config_cdma_international_roaming_indicators" />
+
+
+    <!-- set the system language as value of EF LI/EF PL -->
+    <bool name="config_use_sim_language_file">true</bool>
 </resources>
diff --git a/core/res/res/values/dimens_material.xml b/core/res/res/values/dimens_material.xml
index f7ebbe4..dd1f815 100644
--- a/core/res/res/values/dimens_material.xml
+++ b/core/res/res/values/dimens_material.xml
@@ -87,9 +87,9 @@
     <dimen name="floating_window_margin_bottom">32dp</dimen>
 
     <!-- Elevation when button is pressed -->
-    <dimen name="button_elevation_material">1dp</dimen>
+    <dimen name="button_elevation_material">4dp</dimen>
     <!-- Z translation to apply when button is pressed -->
-    <dimen name="button_pressed_z_material">2dp</dimen>
+    <dimen name="button_pressed_z_material">6dp</dimen>
     <!-- Default insets (outer padding) around buttons -->
     <dimen name="button_inset_vertical_material">6dp</dimen>
     <dimen name="button_inset_horizontal_material">@dimen/control_inset_material</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index a9123d1..e861ab2 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2138,5 +2138,7 @@
   <java-symbol type="string" name="system_error_wipe_data" />
   <java-symbol type="string" name="system_error_manufacturer" />
   <java-symbol type="dimen" name="fast_scroller_minimum_touch_target" />
+  <java-symbol type="array" name="config_cdma_international_roaming_indicators" />
 
+  <java-symbol type="bool" name="config_use_sim_language_file" />
 </resources>
diff --git a/data/keyboards/Vendor_046d_Product_b501.kl b/data/keyboards/Vendor_046d_Product_b501.kl
new file mode 100644
index 0000000..496ddc3
--- /dev/null
+++ b/data/keyboards/Vendor_046d_Product_b501.kl
@@ -0,0 +1,65 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Logitech Bluetooth wireless gamepad (RedHawk)
+
+key 304 BUTTON_A
+key 305 BUTTON_B
+key 307 BUTTON_X
+key 308 BUTTON_Y
+key 310 BUTTON_L1
+key 311 BUTTON_R1
+key 312 BUTTON_L2
+key 313 BUTTON_R2
+
+key 314 BUTTON_SELECT
+key 315 BUTTON_START
+key 316 BUTTON_MODE
+key 317 BUTTON_THUMBL
+key 318 BUTTON_THUMBR
+
+key 103 DPAD_UP
+key 105 DPAD_LEFT
+key 106 DPAD_RIGHT
+key 108 DPAD_DOWN
+key 353 DPAD_CENTER
+
+key 113 VOLUME_MUTE
+key 114 VOLUME_DOWN
+key 115 VOLUME_UP
+key 152 POWER
+key 163 MEDIA_NEXT
+key 164 MEDIA_PLAY_PAUSE
+key 165 MEDIA_PREVIOUS
+
+key 158 BACK
+key 172 HOME
+
+key 217 SEARCH
+key 580 APP_SWITCH
+key 582 ASSIST
+
+axis 0x00 X
+axis 0x01 Y
+axis 0x02 Z
+axis 0x05 RZ
+axis 0x09 RTRIGGER
+axis 0x0a LTRIGGER
+axis 0x10 HAT_X
+axis 0x11 HAT_Y
+
+led 0x00 CONTROLLER_1
+led 0x01 CONTROLLER_2
+led 0x02 CONTROLLER_3
+led 0x03 CONTROLLER_4
diff --git a/data/keyboards/Vendor_1532_Product_0900.kl b/data/keyboards/Vendor_1532_Product_0900.kl
new file mode 100644
index 0000000..c2fc1b4
--- /dev/null
+++ b/data/keyboards/Vendor_1532_Product_0900.kl
@@ -0,0 +1,42 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Razer Serval
+
+key 304 BUTTON_A
+key 305 BUTTON_B
+key 307 BUTTON_X
+key 308 BUTTON_Y
+key 310 BUTTON_L1
+key 311 BUTTON_R1
+key 316 BUTTON_MODE
+key 317 BUTTON_THUMBL
+key 318 BUTTON_THUMBR
+
+key 158 BACK
+key 172 HOME
+
+axis 0x00 X
+axis 0x01 Y
+axis 0x02 Z
+axis 0x05 RZ
+axis 0x09 RTRIGGER
+axis 0x0a LTRIGGER
+axis 0x10 HAT_X
+axis 0x11 HAT_Y
+
+led 0x00 CONTROLLER_1
+led 0x01 CONTROLLER_2
+led 0x02 CONTROLLER_3
+led 0x03 CONTROLLER_4
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd
index 775c424..59bf71c 100644
--- a/docs/html/guide/topics/manifest/uses-feature-element.jd
+++ b/docs/html/guide/topics/manifest/uses-feature-element.jd
@@ -560,7 +560,7 @@
        <td></td>
     </tr>
     <tr>
-       <td rowspan="12">Camera</td>
+       <td rowspan="10">Camera</td>
        <td><code>android.hardware.camera</code></td>
        <td>The application uses the device's camera. If the device supports
            multiple cameras, the application uses the camera that facing
@@ -609,14 +609,6 @@
   <td><code>android.hardware.camera.capability.raw</code></td>
   <td>The application uses a a camera device with the <code>RAW</code> capability.</td>
 </tr>
-<tr>
-  <td><code>android.hardware.camera.capability.burst_capture</code></td>
-  <td>The application uses a a camera device with the <code>BURST_CAPTURE</code> capability.</td>
-</tr>
-<tr>
-  <td><code>android.hardware.camera.capability.read_sensor_settings</code></td>
-  <td>The application uses a a camera device with the <code>READ_SENSOR_SETTINGS</code> capability.</td>
-</tr>
 
 <tr>
   <td>Infrared</td>
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index aa32541..75bd067 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -123,8 +123,8 @@
     setSurface(window);
 }
 
-void CanvasContext::pauseSurface(ANativeWindow* window) {
-    stopDrawing();
+bool CanvasContext::pauseSurface(ANativeWindow* window) {
+    return mRenderThread.removeFrameCallback(this);
 }
 
 // TODO: don't pass viewport size, it's automatic via EGL
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 435244e..0cc2c7c 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -67,7 +67,7 @@
 
     bool initialize(ANativeWindow* window);
     void updateSurface(ANativeWindow* window);
-    void pauseSurface(ANativeWindow* window);
+    bool pauseSurface(ANativeWindow* window);
     bool hasSurface() { return mNativeWindow.get(); }
 
     void setup(int width, int height, const Vector3& lightCenter, float lightRadius,
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 5d55ea6..6d063a4 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -156,15 +156,14 @@
 }
 
 CREATE_BRIDGE2(pauseSurface, CanvasContext* context, ANativeWindow* window) {
-    args->context->pauseSurface(args->window);
-    return NULL;
+    return (void*) args->context->pauseSurface(args->window);
 }
 
-void RenderProxy::pauseSurface(const sp<ANativeWindow>& window) {
+bool RenderProxy::pauseSurface(const sp<ANativeWindow>& window) {
     SETUP_TASK(pauseSurface);
     args->context = mContext;
     args->window = window.get();
-    postAndWait(task);
+    return (bool) postAndWait(task);
 }
 
 CREATE_BRIDGE7(setup, CanvasContext* context, int width, int height,
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 4989b14..fd1fe05 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -69,7 +69,7 @@
 
     ANDROID_API bool initialize(const sp<ANativeWindow>& window);
     ANDROID_API void updateSurface(const sp<ANativeWindow>& window);
-    ANDROID_API void pauseSurface(const sp<ANativeWindow>& window);
+    ANDROID_API bool pauseSurface(const sp<ANativeWindow>& window);
     ANDROID_API void setup(int width, int height, const Vector3& lightCenter, float lightRadius,
             uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
     ANDROID_API void setOpaque(bool opaque);
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index f887103..38cb4cd 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -314,9 +314,11 @@
     mPendingRegistrationFrameCallbacks.insert(callback);
 }
 
-void RenderThread::removeFrameCallback(IFrameCallback* callback) {
-    mFrameCallbacks.erase(callback);
-    mPendingRegistrationFrameCallbacks.erase(callback);
+bool RenderThread::removeFrameCallback(IFrameCallback* callback) {
+    size_t erased;
+    erased = mFrameCallbacks.erase(callback);
+    erased |= mPendingRegistrationFrameCallbacks.erase(callback);
+    return erased;
 }
 
 void RenderThread::pushBackFrameCallback(IFrameCallback* callback) {
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index c461f3a..4126d02 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -80,7 +80,7 @@
 
     // Mimics android.view.Choreographer
     void postFrameCallback(IFrameCallback* callback);
-    void removeFrameCallback(IFrameCallback* callback);
+    bool removeFrameCallback(IFrameCallback* callback);
     // If the callback is currently registered, it will be pushed back until
     // the next vsync. If it is not currently registered this does nothing.
     void pushBackFrameCallback(IFrameCallback* callback);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
index 10baf23..05a5f66 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
@@ -25,6 +25,6 @@
      * Turns on debugging information for the whole Keyguard. This is very verbose and should only
      * be used temporarily for debugging.
      */
-    public static final boolean DEBUG = true;
+    public static final boolean DEBUG = false;
     public static final boolean DEBUG_SIM_STATES = true;
 }
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 7f1314d..ff07dd7 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -1303,16 +1303,15 @@
         // that don't return the complete set of values and have different types. In Keyguard we
         // need IccCardConstants, but TelephonyManager would only give us
         // TelephonyManager.SIM_STATE*, so we retrieve it manually.
-        final int phoneId = SubscriptionManager.getPhoneId(subId);
-        final String stateString = TelephonyManager.getTelephonyProperty(phoneId,
-                TelephonyProperties.PROPERTY_SIM_STATE, "");
+        final TelephonyManager tele = TelephonyManager.from(mContext);
+        int simState =  tele.getSimState(slotId);
         State state;
         try {
-            state = State.valueOf(stateString);
+            state = State.intToState(simState);
         } catch(IllegalArgumentException ex) {
-            Log.w(TAG, "Unknown sim state: " + stateString);
+            Log.w(TAG, "Unknown sim state: " + simState);
             state = State.UNKNOWN;
-        }
+	}
         mSimDatas.put(subId, new SimData(state, slotId, subId));
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 2623db3..33a36f6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -530,11 +530,12 @@
 
     /** Resets the focused task. */
     void resetFocusedTask() {
-        if ((mStack != null) && (0 <= mFocusedTaskIndex) &&
-                (mFocusedTaskIndex < mStack.getTaskCount())) {
+        if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
             Task t = mStack.getTasks().get(mFocusedTaskIndex);
             TaskView tv = getChildViewForTask(t);
-            tv.unsetFocusedTask();
+            if (tv != null) {
+                tv.unsetFocusedTask();
+            }
         }
         mFocusedTaskIndex = -1;
     }
diff --git a/services/core/java/com/android/server/MmsServiceBroker.java b/services/core/java/com/android/server/MmsServiceBroker.java
index b1c4955..83b1919 100644
--- a/services/core/java/com/android/server/MmsServiceBroker.java
+++ b/services/core/java/com/android/server/MmsServiceBroker.java
@@ -207,20 +207,6 @@
         return mTelephonyManager;
     }
 
-    /*
-     * Throws a security exception unless the caller has carrier privilege.
-     */
-    private void enforceCarrierPrivilege() {
-        final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid());
-        for (String pkg : packages) {
-            if (getTelephonyManager().checkCarrierPrivilegesForPackage(pkg) ==
-                    TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
-                return;
-            }
-        }
-        throw new SecurityException("No carrier privilege");
-    }
-
     private String getCallingPackageName() {
         final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid());
         if (packages != null && packages.length > 0) {
@@ -270,19 +256,6 @@
         }
 
         @Override
-        public void updateMmsSendStatus(int messageRef, byte[] pdu, int status)
-                throws RemoteException {
-            enforceCarrierPrivilege();
-            getServiceGuarded().updateMmsSendStatus(messageRef, pdu, status);
-        }
-
-        @Override
-        public void updateMmsDownloadStatus(int messageRef, int status) throws RemoteException {
-            enforceCarrierPrivilege();
-            getServiceGuarded().updateMmsDownloadStatus(messageRef, status);
-        }
-
-        @Override
         public Bundle getCarrierConfigValues(int subId) throws RemoteException {
             Slog.d(TAG, "getCarrierConfigValues() by " + getCallingPackageName());
             return getServiceGuarded().getCarrierConfigValues(subId);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 57a8967..6f1e851 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4539,26 +4539,35 @@
         try {
             IMountService ms = PackageHelper.getMountService();
             if (ms != null) {
-                final long interval = android.provider.Settings.Global.getLong(
-                        mContext.getContentResolver(),
-                        android.provider.Settings.Global.FSTRIM_MANDATORY_INTERVAL,
-                        DEFAULT_MANDATORY_FSTRIM_INTERVAL);
-                if (interval > 0) {
-                    final long timeSinceLast = System.currentTimeMillis() - ms.lastMaintenance();
-                    if (timeSinceLast > interval) {
-                        Slog.w(TAG, "No disk maintenance in " + timeSinceLast
-                                + "; running immediately");
-                        if (!isFirstBoot()) {
-                            try {
-                                ActivityManagerNative.getDefault().showBootMessage(
-                                        mContext.getResources().getString(
-                                                R.string.android_upgrading_fstrim), true);
-                            } catch (RemoteException e) {
-                            }
+                final boolean isUpgrade = isUpgrade();
+                boolean doTrim = isUpgrade;
+                if (doTrim) {
+                    Slog.w(TAG, "Running disk maintenance immediately due to system update");
+                } else {
+                    final long interval = android.provider.Settings.Global.getLong(
+                            mContext.getContentResolver(),
+                            android.provider.Settings.Global.FSTRIM_MANDATORY_INTERVAL,
+                            DEFAULT_MANDATORY_FSTRIM_INTERVAL);
+                    if (interval > 0) {
+                        final long timeSinceLast = System.currentTimeMillis() - ms.lastMaintenance();
+                        if (timeSinceLast > interval) {
+                            doTrim = true;
+                            Slog.w(TAG, "No disk maintenance in " + timeSinceLast
+                                    + "; running immediately");
                         }
-                        ms.runMaintenance();
                     }
                 }
+                if (doTrim) {
+                    if (!isFirstBoot()) {
+                        try {
+                            ActivityManagerNative.getDefault().showBootMessage(
+                                    mContext.getResources().getString(
+                                            R.string.android_upgrading_fstrim), true);
+                        } catch (RemoteException e) {
+                        }
+                    }
+                    ms.runMaintenance();
+                }
             } else {
                 Slog.e(TAG, "Mount service unavailable!");
             }
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index f6e8bcf..c0d54e1 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -118,7 +118,7 @@
     private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.3f;
 
     private static final int DEFAULT_APP_TRANSITION_DURATION = 250;
-    private static final int THUMBNAIL_APP_TRANSITION_DURATION = 300;
+    private static final int THUMBNAIL_APP_TRANSITION_DURATION = 325;
     private static final int THUMBNAIL_APP_TRANSITION_ALPHA_DURATION = 325;
 
     private final Context mContext;
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 8c2a4eb..559a58c 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -167,10 +167,40 @@
 
     private int mVoiceRegState = STATE_OUT_OF_SERVICE;
     private int mDataRegState = STATE_OUT_OF_SERVICE;
-    private boolean mRoaming;
-    private String mOperatorAlphaLong;
-    private String mOperatorAlphaShort;
-    private String mOperatorNumeric;
+
+    /**
+     * Roaming type
+     * HOME : in home network
+     * @hide
+     */
+    public static final int ROAMING_TYPE_NOT_ROAMING = 0;
+    /**
+     * Roaming type
+     * UNKNOWN : in a roaming network, but we can not tell if it's domestic or international
+     * @hide
+     */
+    public static final int ROAMING_TYPE_UNKNOWN = 1;
+    /**
+     * Roaming type
+     * DOMESTIC : in domestic roaming network
+     * @hide
+     */
+    public static final int ROAMING_TYPE_DOMESTIC = 2;
+    /**
+     * Roaming type
+     * INTERNATIONAL : in international roaming network
+     * @hide
+     */
+    public static final int ROAMING_TYPE_INTERNATIONAL = 3;
+
+    private int mVoiceRoamingType;
+    private int mDataRoamingType;
+    private String mVoiceOperatorAlphaLong;
+    private String mVoiceOperatorAlphaShort;
+    private String mVoiceOperatorNumeric;
+    private String mDataOperatorAlphaLong;
+    private String mDataOperatorAlphaShort;
+    private String mDataOperatorNumeric;
     private boolean mIsManualNetworkSelection;
 
     private boolean mIsEmergencyOnly;
@@ -187,6 +217,29 @@
     private int mCdmaEriIconMode;
 
     /**
+     * get String description of roaming type
+     * @hide
+     */
+    public static final String getRoamingLogString(int roamingType) {
+        switch (roamingType) {
+            case ROAMING_TYPE_NOT_ROAMING:
+                return "home";
+
+            case ROAMING_TYPE_UNKNOWN:
+                return "roaming";
+
+            case ROAMING_TYPE_DOMESTIC:
+                return "Domestic Roaming";
+
+            case ROAMING_TYPE_INTERNATIONAL:
+                return "International Roaming";
+
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+    /**
      * Create a new ServiceState from a intent notifier Bundle
      *
      * This method is used by PhoneStateIntentReceiver and maybe by
@@ -221,10 +274,14 @@
     protected void copyFrom(ServiceState s) {
         mVoiceRegState = s.mVoiceRegState;
         mDataRegState = s.mDataRegState;
-        mRoaming = s.mRoaming;
-        mOperatorAlphaLong = s.mOperatorAlphaLong;
-        mOperatorAlphaShort = s.mOperatorAlphaShort;
-        mOperatorNumeric = s.mOperatorNumeric;
+        mVoiceRoamingType = s.mVoiceRoamingType;
+        mDataRoamingType = s.mDataRoamingType;
+        mVoiceOperatorAlphaLong = s.mVoiceOperatorAlphaLong;
+        mVoiceOperatorAlphaShort = s.mVoiceOperatorAlphaShort;
+        mVoiceOperatorNumeric = s.mVoiceOperatorNumeric;
+        mDataOperatorAlphaLong = s.mDataOperatorAlphaLong;
+        mDataOperatorAlphaShort = s.mDataOperatorAlphaShort;
+        mDataOperatorNumeric = s.mDataOperatorNumeric;
         mIsManualNetworkSelection = s.mIsManualNetworkSelection;
         mRilVoiceRadioTechnology = s.mRilVoiceRadioTechnology;
         mRilDataRadioTechnology = s.mRilDataRadioTechnology;
@@ -244,10 +301,14 @@
     public ServiceState(Parcel in) {
         mVoiceRegState = in.readInt();
         mDataRegState = in.readInt();
-        mRoaming = in.readInt() != 0;
-        mOperatorAlphaLong = in.readString();
-        mOperatorAlphaShort = in.readString();
-        mOperatorNumeric = in.readString();
+        mVoiceRoamingType = in.readInt();
+        mDataRoamingType = in.readInt();
+        mVoiceOperatorAlphaLong = in.readString();
+        mVoiceOperatorAlphaShort = in.readString();
+        mVoiceOperatorNumeric = in.readString();
+        mDataOperatorAlphaLong = in.readString();
+        mDataOperatorAlphaShort = in.readString();
+        mDataOperatorNumeric = in.readString();
         mIsManualNetworkSelection = in.readInt() != 0;
         mRilVoiceRadioTechnology = in.readInt();
         mRilDataRadioTechnology = in.readInt();
@@ -264,10 +325,14 @@
     public void writeToParcel(Parcel out, int flags) {
         out.writeInt(mVoiceRegState);
         out.writeInt(mDataRegState);
-        out.writeInt(mRoaming ? 1 : 0);
-        out.writeString(mOperatorAlphaLong);
-        out.writeString(mOperatorAlphaShort);
-        out.writeString(mOperatorNumeric);
+        out.writeInt(mVoiceRoamingType);
+        out.writeInt(mDataRoamingType);
+        out.writeString(mVoiceOperatorAlphaLong);
+        out.writeString(mVoiceOperatorAlphaShort);
+        out.writeString(mVoiceOperatorNumeric);
+        out.writeString(mDataOperatorAlphaLong);
+        out.writeString(mDataOperatorAlphaShort);
+        out.writeString(mDataOperatorNumeric);
         out.writeInt(mIsManualNetworkSelection ? 1 : 0);
         out.writeInt(mRilVoiceRadioTechnology);
         out.writeInt(mRilDataRadioTechnology);
@@ -337,10 +402,45 @@
      *
      * @return true if TS 27.007 7.2 roaming is true
      *              and ONS is different from SPN
-     *
      */
     public boolean getRoaming() {
-        return mRoaming;
+        return getVoiceRoaming() || getDataRoaming();
+    }
+
+    /**
+     * Get current voice network roaming status
+     * @return roaming status
+     * @hide
+     */
+    public boolean getVoiceRoaming() {
+        return mVoiceRoamingType != ROAMING_TYPE_NOT_ROAMING;
+    }
+
+    /**
+     * Get current voice network roaming type
+     * @return roaming type
+     * @hide
+     */
+    public int getVoiceRoamingType() {
+        return mVoiceRoamingType;
+    }
+
+    /**
+     * Get current data network roaming type
+     * @return roaming type
+     * @hide
+     */
+    public boolean getDataRoaming() {
+        return mDataRoamingType != ROAMING_TYPE_NOT_ROAMING;
+    }
+
+    /**
+     * Get current data network roaming type
+     * @return roaming type
+     * @hide
+     */
+    public int getDataRoamingType() {
+        return mDataRoamingType;
     }
 
     /**
@@ -387,7 +487,25 @@
      * @return long name of operator, null if unregistered or unknown
      */
     public String getOperatorAlphaLong() {
-        return mOperatorAlphaLong;
+        return mVoiceOperatorAlphaLong;
+    }
+
+    /**
+     * Get current registered voice network operator name in long alphanumeric format.
+     * @return long name of operator
+     * @hide
+     */
+    public String getVoiceOperatorAlphaLong() {
+        return mVoiceOperatorAlphaLong;
+    }
+
+    /**
+     * Get current registered data network operator name in long alphanumeric format.
+     * @return long name of voice operator
+     * @hide
+     */
+    public String getDataOperatorAlphaLong() {
+        return mDataOperatorAlphaLong;
     }
 
     /**
@@ -398,7 +516,25 @@
      * @return short name of operator, null if unregistered or unknown
      */
     public String getOperatorAlphaShort() {
-        return mOperatorAlphaShort;
+        return mVoiceOperatorAlphaShort;
+    }
+
+    /**
+     * Get current registered voice network operator name in short alphanumeric format.
+     * @return short name of operator, null if unregistered or unknown
+     * @hide
+     */
+    public String getVoiceOperatorAlphaShort() {
+        return mVoiceOperatorAlphaShort;
+    }
+
+    /**
+     * Get current registered data network operator name in short alphanumeric format.
+     * @return short name of operator, null if unregistered or unknown
+     * @hide
+     */
+    public String getDataOperatorAlphaShort() {
+        return mDataOperatorAlphaShort;
     }
 
     /**
@@ -414,7 +550,25 @@
      * {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}.
      */
     public String getOperatorNumeric() {
-        return mOperatorNumeric;
+        return mVoiceOperatorNumeric;
+    }
+
+    /**
+     * Get current registered voice network operator numeric id.
+     * @return numeric format of operator, null if unregistered or unknown
+     * @hide
+     */
+    public String getVoiceOperatorNumeric() {
+        return mVoiceOperatorNumeric;
+    }
+
+    /**
+     * Get current registered data network operator numeric id.
+     * @return numeric format of operator, null if unregistered or unknown
+     * @hide
+     */
+    public String getDataOperatorNumeric() {
+        return mDataOperatorNumeric;
     }
 
     /**
@@ -430,11 +584,15 @@
     public int hashCode() {
         return ((mVoiceRegState * 31)
                 + (mDataRegState * 37)
-                + (mRoaming ? 1 : 0)
+                + mVoiceRoamingType
+                + mDataRoamingType
                 + (mIsManualNetworkSelection ? 1 : 0)
-                + ((null == mOperatorAlphaLong) ? 0 : mOperatorAlphaLong.hashCode())
-                + ((null == mOperatorAlphaShort) ? 0 : mOperatorAlphaShort.hashCode())
-                + ((null == mOperatorNumeric) ? 0 : mOperatorNumeric.hashCode())
+                + ((null == mVoiceOperatorAlphaLong) ? 0 : mVoiceOperatorAlphaLong.hashCode())
+                + ((null == mVoiceOperatorAlphaShort) ? 0 : mVoiceOperatorAlphaShort.hashCode())
+                + ((null == mVoiceOperatorNumeric) ? 0 : mVoiceOperatorNumeric.hashCode())
+                + ((null == mDataOperatorAlphaLong) ? 0 : mDataOperatorAlphaLong.hashCode())
+                + ((null == mDataOperatorAlphaShort) ? 0 : mDataOperatorAlphaShort.hashCode())
+                + ((null == mDataOperatorNumeric) ? 0 : mDataOperatorNumeric.hashCode())
                 + mCdmaRoamingIndicator
                 + mCdmaDefaultRoamingIndicator
                 + (mIsEmergencyOnly ? 1 : 0));
@@ -456,11 +614,15 @@
 
         return (mVoiceRegState == s.mVoiceRegState
                 && mDataRegState == s.mDataRegState
-                && mRoaming == s.mRoaming
                 && mIsManualNetworkSelection == s.mIsManualNetworkSelection
-                && equalsHandlesNulls(mOperatorAlphaLong, s.mOperatorAlphaLong)
-                && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort)
-                && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric)
+                && mVoiceRoamingType == s.mVoiceRoamingType
+                && mDataRoamingType == s.mDataRoamingType
+                && equalsHandlesNulls(mVoiceOperatorAlphaLong, s.mVoiceOperatorAlphaLong)
+                && equalsHandlesNulls(mVoiceOperatorAlphaShort, s.mVoiceOperatorAlphaShort)
+                && equalsHandlesNulls(mVoiceOperatorNumeric, s.mVoiceOperatorNumeric)
+                && equalsHandlesNulls(mDataOperatorAlphaLong, s.mDataOperatorAlphaLong)
+                && equalsHandlesNulls(mDataOperatorAlphaShort, s.mDataOperatorAlphaShort)
+                && equalsHandlesNulls(mDataOperatorNumeric, s.mDataOperatorNumeric)
                 && equalsHandlesNulls(mRilVoiceRadioTechnology, s.mRilVoiceRadioTechnology)
                 && equalsHandlesNulls(mRilDataRadioTechnology, s.mRilDataRadioTechnology)
                 && equalsHandlesNulls(mCssIndicator, s.mCssIndicator)
@@ -548,10 +710,17 @@
         String radioTechnology = rilRadioTechnologyToString(mRilVoiceRadioTechnology);
         String dataRadioTechnology = rilRadioTechnologyToString(mRilDataRadioTechnology);
 
-        return (mVoiceRegState + " " + mDataRegState + " " + (mRoaming ? "roaming" : "home")
-                + " " + mOperatorAlphaLong
-                + " " + mOperatorAlphaShort
-                + " " + mOperatorNumeric
+        return (mVoiceRegState + " " + mDataRegState
+                + " "
+                + "voice " + getRoamingLogString(mVoiceRoamingType)
+                + " "
+                + "data " + getRoamingLogString(mDataRoamingType)
+                + " " + mVoiceOperatorAlphaLong
+                + " " + mVoiceOperatorAlphaShort
+                + " " + mVoiceOperatorNumeric
+                + " " + mDataOperatorAlphaLong
+                + " " + mDataOperatorAlphaShort
+                + " " + mDataOperatorNumeric
                 + " " + (mIsManualNetworkSelection ? "(manual)" : "")
                 + " " + radioTechnology
                 + " " + dataRadioTechnology
@@ -567,10 +736,14 @@
         if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setNullState=" + state);
         mVoiceRegState = state;
         mDataRegState = state;
-        mRoaming = false;
-        mOperatorAlphaLong = null;
-        mOperatorAlphaShort = null;
-        mOperatorNumeric = null;
+        mVoiceRoamingType = ROAMING_TYPE_NOT_ROAMING;
+        mDataRoamingType = ROAMING_TYPE_NOT_ROAMING;
+        mVoiceOperatorAlphaLong = null;
+        mVoiceOperatorAlphaShort = null;
+        mVoiceOperatorNumeric = null;
+        mDataOperatorAlphaLong = null;
+        mDataOperatorAlphaShort = null;
+        mDataOperatorNumeric = null;
         mIsManualNetworkSelection = false;
         mRilVoiceRadioTechnology = 0;
         mRilDataRadioTechnology = 0;
@@ -610,9 +783,29 @@
     }
 
     public void setRoaming(boolean roaming) {
-        mRoaming = roaming;
+        mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING);
+        mDataRoamingType = mVoiceRoamingType;
     }
 
+    /** @hide */
+    public void setVoiceRoaming(boolean roaming) {
+        mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING);
+    }
+
+    /** @hide */
+    public void setVoiceRoamingType(int type) {
+        mVoiceRoamingType = type;
+    }
+
+    /** @hide */
+    public void setDataRoaming(boolean dataRoaming) {
+        mDataRoamingType = (dataRoaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING);
+    }
+
+    /** @hide */
+    public void setDataRoamingType(int type) {
+        mDataRoamingType = type;
+    }
 
     /**
      * @hide
@@ -650,9 +843,26 @@
     }
 
     public void setOperatorName(String longName, String shortName, String numeric) {
-        mOperatorAlphaLong = longName;
-        mOperatorAlphaShort = shortName;
-        mOperatorNumeric = numeric;
+        mVoiceOperatorAlphaLong = longName;
+        mVoiceOperatorAlphaShort = shortName;
+        mVoiceOperatorNumeric = numeric;
+        mDataOperatorAlphaLong = longName;
+        mDataOperatorAlphaShort = shortName;
+        mDataOperatorNumeric = numeric;
+    }
+
+    /** @hide */
+    public void setVoiceOperatorName(String longName, String shortName, String numeric) {
+        mVoiceOperatorAlphaLong = longName;
+        mVoiceOperatorAlphaShort = shortName;
+        mVoiceOperatorNumeric = numeric;
+    }
+
+    /** @hide */
+    public void setDataOperatorName(String longName, String shortName, String numeric) {
+        mDataOperatorAlphaLong = longName;
+        mDataOperatorAlphaShort = shortName;
+        mDataOperatorNumeric = numeric;
     }
 
     /**
@@ -662,7 +872,18 @@
      * @hide
      */
     public void setOperatorAlphaLong(String longName) {
-        mOperatorAlphaLong = longName;
+        mVoiceOperatorAlphaLong = longName;
+        mDataOperatorAlphaLong = longName;
+    }
+
+    /** @hide */
+    public void setVoiceOperatorAlphaLong(String longName) {
+        mVoiceOperatorAlphaLong = longName;
+    }
+
+    /** @hide */
+    public void setDataOperatorAlphaLong(String longName) {
+        mDataOperatorAlphaLong = longName;
     }
 
     public void setIsManualSelection(boolean isManual) {
@@ -689,10 +910,14 @@
     private void setFromNotifierBundle(Bundle m) {
         mVoiceRegState = m.getInt("voiceRegState");
         mDataRegState = m.getInt("dataRegState");
-        mRoaming = m.getBoolean("roaming");
-        mOperatorAlphaLong = m.getString("operator-alpha-long");
-        mOperatorAlphaShort = m.getString("operator-alpha-short");
-        mOperatorNumeric = m.getString("operator-numeric");
+        mVoiceRoamingType = m.getInt("voiceRoamingType");
+        mDataRoamingType = m.getInt("dataRoamingType");
+        mVoiceOperatorAlphaLong = m.getString("operator-alpha-long");
+        mVoiceOperatorAlphaShort = m.getString("operator-alpha-short");
+        mVoiceOperatorNumeric = m.getString("operator-numeric");
+        mDataOperatorAlphaLong = m.getString("data-operator-alpha-long");
+        mDataOperatorAlphaShort = m.getString("data-operator-alpha-short");
+        mDataOperatorNumeric = m.getString("data-operator-numeric");
         mIsManualNetworkSelection = m.getBoolean("manual");
         mRilVoiceRadioTechnology = m.getInt("radioTechnology");
         mRilDataRadioTechnology = m.getInt("dataRadioTechnology");
@@ -713,10 +938,14 @@
     public void fillInNotifierBundle(Bundle m) {
         m.putInt("voiceRegState", mVoiceRegState);
         m.putInt("dataRegState", mDataRegState);
-        m.putBoolean("roaming", Boolean.valueOf(mRoaming));
-        m.putString("operator-alpha-long", mOperatorAlphaLong);
-        m.putString("operator-alpha-short", mOperatorAlphaShort);
-        m.putString("operator-numeric", mOperatorNumeric);
+        m.putInt("voiceRoamingType", mVoiceRoamingType);
+        m.putInt("dataRoamingType", mDataRoamingType);
+        m.putString("operator-alpha-long", mVoiceOperatorAlphaLong);
+        m.putString("operator-alpha-short", mVoiceOperatorAlphaShort);
+        m.putString("operator-numeric", mVoiceOperatorNumeric);
+        m.putString("data-operator-alpha-long", mDataOperatorAlphaLong);
+        m.putString("data-operator-alpha-short", mDataOperatorAlphaShort);
+        m.putString("data-operator-numeric", mDataOperatorNumeric);
         m.putBoolean("manual", Boolean.valueOf(mIsManualNetworkSelection));
         m.putInt("radioTechnology", mRilVoiceRadioTechnology);
         m.putInt("dataRadioTechnology", mRilDataRadioTechnology);
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 40d2e77..abf1ead 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1103,5 +1103,35 @@
         return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId,
                 TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null));
     }
+
+    /**
+     * Returns a constant indicating the state of sim for the subscription.
+     *
+     * @param subId
+     *
+     * {@See TelephonyManager#SIM_STATE_UNKNOWN}
+     * {@See TelephonyManager#SIM_STATE_ABSENT}
+     * {@See TelephonyManager#SIM_STATE_PIN_REQUIRED}
+     * {@See TelephonyManager#SIM_STATE_PUK_REQUIRED}
+     * {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED}
+     * {@See TelephonyManager#SIM_STATE_READY}
+     * {@See TelephonyManager#SIM_STATE_NOT_READY}
+     * {@See TelephonyManager#SIM_STATE_PERM_DISABLED}
+     * {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR}
+     *
+     * {@hide}
+     */
+    public static int getSimStateForSubscriber(int subId) {
+        int simState;
+
+        try {
+            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+            simState = iSub.getSimStateForSubscriber(subId);
+        } catch (RemoteException ex) {
+            simState = TelephonyManager.SIM_STATE_UNKNOWN;
+        }
+        logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId);
+        return simState;
+    }
 }
 
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index de2a6da..751e11b 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -1416,10 +1416,14 @@
     //
     //
 
-    /** SIM card state: Unknown. Signifies that the SIM is in transition
-     *  between states. For example, when the user inputs the SIM pin
-     *  under PIN_REQUIRED state, a query for sim status returns
-     *  this state before turning to SIM_STATE_READY. */
+    /**
+     * SIM card state: Unknown. Signifies that the SIM is in transition
+     * between states. For example, when the user inputs the SIM pin
+     * under PIN_REQUIRED state, a query for sim status returns
+     * this state before turning to SIM_STATE_READY.
+     *
+     * These are the ordinal value of IccCardConstants.State.
+     */
     public static final int SIM_STATE_UNKNOWN = 0;
     /** SIM card state: no SIM card is available in the device */
     public static final int SIM_STATE_ABSENT = 1;
@@ -1427,14 +1431,22 @@
     public static final int SIM_STATE_PIN_REQUIRED = 2;
     /** SIM card state: Locked: requires the user's SIM PUK to unlock */
     public static final int SIM_STATE_PUK_REQUIRED = 3;
-    /** SIM card state: Locked: requries a network PIN to unlock */
+    /** SIM card state: Locked: requires a network PIN to unlock */
     public static final int SIM_STATE_NETWORK_LOCKED = 4;
     /** SIM card state: Ready */
     public static final int SIM_STATE_READY = 5;
-    /** SIM card state: SIM Card Error, Sim Card is present but faulty
+    /** SIM card state: SIM Card is NOT READY
      *@hide
      */
-    public static final int SIM_STATE_CARD_IO_ERROR = 6;
+    public static final int SIM_STATE_NOT_READY = 6;
+    /** SIM card state: SIM Card Error, permanently disabled
+     *@hide
+     */
+    public static final int SIM_STATE_PERM_DISABLED = 7;
+    /** SIM card state: SIM Card Error, present but faulty
+     *@hide
+     */
+    public static final int SIM_STATE_CARD_IO_ERROR = 8;
 
     /**
      * @return true if a ICC card is present
@@ -1464,8 +1476,7 @@
     }
 
     /**
-     * Returns a constant indicating the state of the
-     * device SIM card.
+     * Returns a constant indicating the state of the default SIM card.
      *
      * @see #SIM_STATE_UNKNOWN
      * @see #SIM_STATE_ABSENT
@@ -1473,6 +1484,8 @@
      * @see #SIM_STATE_PUK_REQUIRED
      * @see #SIM_STATE_NETWORK_LOCKED
      * @see #SIM_STATE_READY
+     * @see #SIM_STATE_NOT_READY
+     * @see #SIM_STATE_PERM_DISABLED
      * @see #SIM_STATE_CARD_IO_ERROR
      */
     public int getSimState() {
@@ -1480,10 +1493,9 @@
     }
 
     /**
-     * Returns a constant indicating the state of the
-     * device SIM card in a slot.
+     * Returns a constant indicating the state of the device SIM card in a slot.
      *
-     * @param slotId
+     * @param slotIdx
      *
      * @see #SIM_STATE_UNKNOWN
      * @see #SIM_STATE_ABSENT
@@ -1491,39 +1503,20 @@
      * @see #SIM_STATE_PUK_REQUIRED
      * @see #SIM_STATE_NETWORK_LOCKED
      * @see #SIM_STATE_READY
+     * @see #SIM_STATE_NOT_READY
+     * @see #SIM_STATE_PERM_DISABLED
+     * @see #SIM_STATE_CARD_IO_ERROR
      */
     /** {@hide} */
-    // FIXME the argument to pass is subId ??
-    public int getSimState(int slotId) {
-        int[] subId = SubscriptionManager.getSubId(slotId);
+    public int getSimState(int slotIdx) {
+        int[] subId = SubscriptionManager.getSubId(slotIdx);
         if (subId == null || subId.length == 0) {
-            return SIM_STATE_ABSENT;
-        }
-        // FIXME Do not use a property to determine SIM_STATE, call
-        // appropriate method on some object.
-        int phoneId = SubscriptionManager.getPhoneId(subId[0]);
-        String prop = getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_SIM_STATE, "");
-        if ("ABSENT".equals(prop)) {
-            return SIM_STATE_ABSENT;
-        }
-        else if ("PIN_REQUIRED".equals(prop)) {
-            return SIM_STATE_PIN_REQUIRED;
-        }
-        else if ("PUK_REQUIRED".equals(prop)) {
-            return SIM_STATE_PUK_REQUIRED;
-        }
-        else if ("NETWORK_LOCKED".equals(prop)) {
-            return SIM_STATE_NETWORK_LOCKED;
-        }
-        else if ("READY".equals(prop)) {
-            return SIM_STATE_READY;
-        }
-        else if ("CARD_IO_ERROR".equals(prop)) {
-            return SIM_STATE_CARD_IO_ERROR;
-        }
-        else {
+            Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT");
             return SIM_STATE_UNKNOWN;
         }
+        int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]);
+        Rlog.d(TAG, "getSimState: simState=" + simState + " slotIdx=" + slotIdx);
+        return simState;
     }
 
     /**
@@ -1535,7 +1528,7 @@
      * @see #getSimState
      */
     public String getSimOperator() {
-        int subId = mSubscriptionManager.getDefaultDataSubId();
+        int subId = SubscriptionManager.getDefaultDataSubId();
         if (!SubscriptionManager.isUsableSubIdValue(subId)) {
             subId = SubscriptionManager.getDefaultSmsSubId();
             if (!SubscriptionManager.isUsableSubIdValue(subId)) {
@@ -2758,8 +2751,6 @@
      * @hide
      */
     public static void setTelephonyProperty(int phoneId, String property, String value) {
-        Rlog.d(TAG, "setTelephonyProperty property: " + property + " phoneId: " + phoneId +
-                " value: " + value);
         String propVal = "";
         String p[] = null;
         String prop = SystemProperties.get(property);
@@ -2773,7 +2764,8 @@
         }
 
         if (!SubscriptionManager.isValidPhoneId(phoneId)) {
-            Rlog.d(TAG, "setTelephonyProperty invalid phone id");
+            Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
+                    " property=" + property + " value: " + value + " prop=" + prop);
             return;
         }
 
@@ -2792,13 +2784,15 @@
             }
         }
 
-        // TODO: workaround for QC
-        if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) {
-            Rlog.d(TAG, "setTelephonyProperty length too long:" + property + ", " + propVal);
+        if (property.length() > SystemProperties.PROP_NAME_MAX
+                || propVal.length() > SystemProperties.PROP_VALUE_MAX) {
+            Rlog.d(TAG, "setTelephonyProperty: property to long phoneId=" + phoneId +
+                    " property=" + property + " value: " + value + " propVal=" + propVal);
             return;
         }
 
-        Rlog.d(TAG, "setTelephonyProperty property=" + property + " propVal=" + propVal);
+        Rlog.d(TAG, "setTelephonyProperty: success phoneId=" + phoneId +
+                " property=" + property + " value: " + value + " propVal=" + propVal);
         SystemProperties.set(property, propVal);
     }
 
@@ -2904,13 +2898,16 @@
                 propVal = values[phoneId];
             }
         }
+        Rlog.d(TAG, "getTelephonyProperty: return propVal='" + propVal + "' phoneId=" + phoneId
+                + " property='" + property + "' defaultVal='" + defaultVal + "' prop=" + prop);
         return propVal == null ? defaultVal : propVal;
     }
 
     /** @hide */
     public int getSimCount() {
+        // FIXME Need to get it from Telephony Dev Controller when that gets implemented!
+        // and then this method shouldn't be used at all!
         if(isMultiSimEnabled()) {
-            //FIXME Need to get it from Telephony Devcontroller
             return 2;
         } else {
             return 1;
diff --git a/telephony/java/com/android/ims/ImsReasonInfo.java b/telephony/java/com/android/ims/ImsReasonInfo.java
index 2ab9648..2482249 100644
--- a/telephony/java/com/android/ims/ImsReasonInfo.java
+++ b/telephony/java/com/android/ims/ImsReasonInfo.java
@@ -195,6 +195,10 @@
     public static final int CODE_USER_IGNORE = 503;
     // User declines an incoming call
     public static final int CODE_USER_DECLINE = 504;
+    // Device declines/ends a call due to low battery
+    public static final int CODE_LOW_BATTERY = 505;
+    // Device declines call due to blacklisted call ID
+    public static final int CODE_BLACKLISTED_CALL_ID = 506;
     // IMS -> Telephony
     // The call is terminated by the network or remote user
     public static final int CODE_USER_TERMINATED_BY_REMOTE = 510;
diff --git a/telephony/java/com/android/internal/telephony/IMms.aidl b/telephony/java/com/android/internal/telephony/IMms.aidl
index 0322499..49ac400 100644
--- a/telephony/java/com/android/internal/telephony/IMms.aidl
+++ b/telephony/java/com/android/internal/telephony/IMms.aidl
@@ -61,40 +61,6 @@
             in PendingIntent downloadedIntent);
 
     /**
-     * Update the status of a pending (send-by-IP) MMS message handled by the carrier app.
-     * If the carrier app fails to send this message, it may be resent via carrier network
-     * depending on the status code.
-     *
-     * The caller should have carrier privileges.
-     * @see android.telephony.TelephonyManager.hasCarrierPrivileges
-     *
-     * @param messageRef the reference number of the MMS message.
-     * @param pdu non-empty (contains the SendConf PDU) if the message was sent successfully,
-     *   otherwise, this param should be null.
-     * @param status send status. It can be Activity.RESULT_OK or one of the MMS error codes.
-     *   If status is Activity.RESULT_OK, the MMS was sent successfully.
-     *   If status is MMS_ERROR_RETRY, this message would be resent via carrier
-     *   network. The message will not be resent for other MMS error statuses.
-     */
-    void updateMmsSendStatus(int messageRef, in byte[] pdu, in int status);
-
-    /**
-     * Update the status of a pending (download-by-IP) MMS message handled by the carrier app.
-     * If the carrier app fails to download this message, it may be re-downloaded via carrier
-     * network depending on the status code.
-     *
-     * The caller should have carrier privileges.
-     * @see android.telephony.TelephonyManager.hasCarrierPrivileges
-     *
-     * @param messageRef the reference number of the MMS message.
-     * @param status download status.  It can be Activity.RESULT_OK or one of the MMS error codes.
-     *   If status is Activity.RESULT_OK, the MMS was downloaded successfully.
-     *   If status is MMS_ERROR_RETRY, this message would be re-downloaded via carrier
-     *   network. The message will not be re-downloaded for other MMS error statuses.
-     */
-    void updateMmsDownloadStatus(int messageRef, in int status);
-
-    /**
      * Get carrier-dependent configuration values.
      *
      * @param subId the SIM id
diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl
index 15fa340..6fdf121 100644
--- a/telephony/java/com/android/internal/telephony/ISms.aidl
+++ b/telephony/java/com/android/internal/telephony/ISms.aidl
@@ -224,17 +224,6 @@
     void injectSmsPdu(in byte[] pdu, String format, in PendingIntent receivedIntent);
 
     /**
-     * Update the status of a pending (send-by-IP) SMS message and resend by PSTN if necessary.
-     * This outbound message was handled by the carrier app. If the carrier app fails to send
-     * this message, it would be resent by PSTN.
-     *
-     * @param messageRef the reference number of the SMS message.
-     * @param success True if and only if the message was sent successfully. If its value is
-     *  false, this message should be resent via PSTN.
-     */
-    void updateSmsSendStatus(int messageRef, boolean success);
-
-    /**
      * Send a multi-part text based SMS.
      *
      * @param destinationAddress the address to send the message to
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index ca82083..acbc0aa 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -164,4 +164,11 @@
     void clearDefaultsForInactiveSubIds();
 
     int[] getActiveSubIdList();
+
+    /**
+     * Get the SIM state for the subscriber
+     * @return SIM state as the ordinal of IccCardConstants.State
+     */
+    int getSimStateForSubscriber(int subId);
+
 }
diff --git a/telephony/java/com/android/internal/telephony/IccCardConstants.java b/telephony/java/com/android/internal/telephony/IccCardConstants.java
index 8029713..c1e2518 100644
--- a/telephony/java/com/android/internal/telephony/IccCardConstants.java
+++ b/telephony/java/com/android/internal/telephony/IccCardConstants.java
@@ -15,12 +15,14 @@
  */
 package com.android.internal.telephony;
 
+import android.telephony.TelephonyManager;
+
 /**
  * {@hide}
  */
 public class IccCardConstants {
 
-    /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */
+    /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */
     public static final String INTENT_KEY_ICC_STATE = "ss";
     /* UNKNOWN means the ICC state is unknown */
     public static final String INTENT_VALUE_ICC_UNKNOWN = "UNKNOWN";
@@ -32,13 +34,17 @@
     static public final String INTENT_VALUE_ICC_CARD_IO_ERROR = "CARD_IO_ERROR";
     /* LOCKED means ICC is locked by pin or by network */
     public static final String INTENT_VALUE_ICC_LOCKED = "LOCKED";
+    //TODO: we can remove this state in the future if Bug 18489776 analysis
+    //#42's first race condition is resolved
+    /* INTERNAL LOCKED means ICC is locked by pin or by network */
+    public static final String INTENT_VALUE_ICC_INTERNAL_LOCKED = "INTERNAL_LOCKED";
     /* READY means ICC is ready to access */
     public static final String INTENT_VALUE_ICC_READY = "READY";
     /* IMSI means ICC IMSI is ready in property */
     public static final String INTENT_VALUE_ICC_IMSI = "IMSI";
     /* LOADED means all ICC records, including IMSI, are loaded */
     public static final String INTENT_VALUE_ICC_LOADED = "LOADED";
-    /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */
+    /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */
     public static final String INTENT_KEY_LOCKED_REASON = "reason";
     /* PIN means ICC is locked on PIN1 */
     public static final String INTENT_VALUE_LOCKED_ON_PIN = "PIN";
@@ -56,17 +62,19 @@
      * UNKNOWN is a transient state, for example, after user inputs ICC pin under
      * PIN_REQUIRED state, the query for ICC status returns UNKNOWN before it
      * turns to READY
+     *
+     * The ordinal values much match {@link TelephonyManager#SIM_STATE_UNKNOWN} ...
      */
     public enum State {
-        UNKNOWN,
-        ABSENT,
-        PIN_REQUIRED,
-        PUK_REQUIRED,
-        NETWORK_LOCKED,
-        READY,
-        NOT_READY,
-        PERM_DISABLED,
-        CARD_IO_ERROR;
+        UNKNOWN,        /** ordinal(0) == {@See TelephonyManager#SIM_STATE_UNKNOWN} */
+        ABSENT,         /** ordinal(1) == {@See TelephonyManager#SIM_STATE_ABSENT} */
+        PIN_REQUIRED,   /** ordinal(2) == {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} */
+        PUK_REQUIRED,   /** ordinal(3) == {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} */
+        NETWORK_LOCKED, /** ordinal(4) == {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} */
+        READY,          /** ordinal(5) == {@See TelephonyManager#SIM_STATE_READY} */
+        NOT_READY,      /** ordinal(6) == {@See TelephonyManager#SIM_STATE_NOT_READY} */
+        PERM_DISABLED,  /** ordinal(7) == {@See TelephonyManager#SIM_STATE_PERM_DISABLED} */
+        CARD_IO_ERROR;  /** ordinal(8) == {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} */
 
         public boolean isPinLocked() {
             return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED));
@@ -77,5 +85,21 @@
                     || (this == NETWORK_LOCKED) || (this == READY)
                     || (this == PERM_DISABLED) || (this == CARD_IO_ERROR));
         }
+
+        public static State intToState(int state) throws IllegalArgumentException {
+            switch(state) {
+                case 0: return UNKNOWN;
+                case 1: return ABSENT;
+                case 2: return PIN_REQUIRED;
+                case 3: return PUK_REQUIRED;
+                case 4: return NETWORK_LOCKED;
+                case 5: return READY;
+                case 6: return NOT_READY;
+                case 7: return PERM_DISABLED;
+                case 8: return CARD_IO_ERROR;
+                default:
+                    throw new IllegalArgumentException();
+            }
+        }
     }
 }