Merge "Allow override own number as voicemail number for GSM"
diff --git a/proto/src/telephony.proto b/proto/src/telephony.proto
index d49c2b2..31d8ea8 100644
--- a/proto/src/telephony.proto
+++ b/proto/src/telephony.proto
@@ -47,6 +47,9 @@
 
   // Modem power stats
   optional ModemPowerStats modem_power_stats = 8;
+
+  // Hardware revision (EVT, DVT, PVT etc.)
+  optional string hardware_revision = 9;
 }
 
 // The time information
@@ -575,11 +578,11 @@
   IMS_E_UNKNOWN = 0;
   // The operation has succeeded
   IMS_E_SUCCESS = 1;
-  // Sending an SMS over IMS has failed. Do not retry over IMS again or fallback to CS.
+  // Sending SMS over IMS failed. Do not retry over IMS again or fallback to CS.
   IMS_E_SMS_SEND_STATUS_ERROR = 2;
-  // Sending an SMS over IMS has failed. Retry over IMS again.
+  // Sending SMS over IMS failed. Retry over IMS again.
   IMS_E_SMS_SEND_STATUS_ERROR_RETRY = 3;
-  // Sending an SMS over IMS has failed. Fallback to sending the SMS over CS.
+  // Sending SMS over IMS failed. Fallback to sending the SMS over CS.
   IMS_E_SMS_SEND_STATUS_ERROR_FALLBACK = 4;
 }
 
@@ -1386,16 +1389,6 @@
 
       // CB message received
       CB_SMS_RECEIVED = 9;
-
-      // Send an SMS message over ImsService
-      SMS_SEND_IMS_SERVICE = 10;
-
-      // Receive an SMS message result over ImsService
-      SMS_SEND_RESULT_IMS_SERVICE = 11;
-
-      // Receive an SMS message over ImsService
-      SMS_RECEIVED_IMS_SERVICE = 12;
-
     }
 
     // Formats used to encode SMS messages
@@ -1433,6 +1426,12 @@
 
       // Service category of CB message
       optional int32 service_category = 4;
+
+      // Message's serial number
+      optional int32 serial_number = 5;
+
+      // The delivered time (UTC) of the message
+      optional int64 delivered_timestamp_millis = 6;
     }
 
     enum CBMessageType {
@@ -1495,8 +1494,9 @@
 
     // See 3GPP 27.005, 3.2.5 for GSM/UMTS,
     // 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA,
-    // or ImsService for IMS specific error codes (using ImsService specific Event.Type)
-    // -1 if unknown or not applicable
+    // Will map to a SmsManager.RESULT_* code if ims_error is populated
+    // SmsManager can be accessed from
+    // frameworks/base/telephony/java/android/telephony/SmsManager.java
     optional int32 error_code = 10;
 
     // RIL error code
@@ -1509,7 +1509,7 @@
     optional CBMessage cell_broadcast_message = 13;
 
     // ImsService error code.
-    optional ImsServiceErrno imsError = 14;
+    optional ImsServiceErrno ims_error = 14;
   }
 
   // Time when session has started, in minutes since epoch,
diff --git a/src/java/com/android/internal/telephony/CarrierResolver.java b/src/java/com/android/internal/telephony/CarrierResolver.java
index 0c7950f..14d093f 100644
--- a/src/java/com/android/internal/telephony/CarrierResolver.java
+++ b/src/java/com/android/internal/telephony/CarrierResolver.java
@@ -375,7 +375,6 @@
                     .ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
             intent.putExtra(TelephonyManager.EXTRA_CARRIER_ID, mCarrierId);
             intent.putExtra(TelephonyManager.EXTRA_CARRIER_NAME, mCarrierName);
-            intent.putExtra(TelephonyManager.EXTRA_MNO_CARRIER_ID, mMnoCarrierId);
             intent.putExtra(TelephonyManager.EXTRA_SUBSCRIPTION_ID, mPhone.getSubId());
             mContext.sendBroadcast(intent);
 
@@ -383,10 +382,8 @@
             ContentValues cv = new ContentValues();
             cv.put(CarrierId.CARRIER_ID, mCarrierId);
             cv.put(CarrierId.CARRIER_NAME, mCarrierName);
-            cv.put(CarrierId.MNO_CARRIER_ID, mMnoCarrierId);
             mContext.getContentResolver().update(
-                    Uri.withAppendedPath(CarrierId.CONTENT_URI,
-                            Integer.toString(mPhone.getSubId())), cv, null, null);
+                    Telephony.CarrierId.getUriForSubscriptionId(mPhone.getSubId()), cv, null, null);
         }
 
         update = false;
diff --git a/src/java/com/android/internal/telephony/CellBroadcastHandler.java b/src/java/com/android/internal/telephony/CellBroadcastHandler.java
index 2261340..4c4148d 100644
--- a/src/java/com/android/internal/telephony/CellBroadcastHandler.java
+++ b/src/java/com/android/internal/telephony/CellBroadcastHandler.java
@@ -94,7 +94,8 @@
         TelephonyMetrics metrics = TelephonyMetrics.getInstance();
         metrics.writeNewCBSms(mPhone.getPhoneId(), message.getMessageFormat(),
                 message.getMessagePriority(), message.isCmasMessage(), message.isEtwsMessage(),
-                message.getServiceCategory());
+                message.getServiceCategory(), message.getSerialNumber(),
+                System.currentTimeMillis());
 
         String msg;
         Intent intent;
diff --git a/src/java/com/android/internal/telephony/CellularNetworkService.java b/src/java/com/android/internal/telephony/CellularNetworkService.java
index edbbcda..a8dcee7 100644
--- a/src/java/com/android/internal/telephony/CellularNetworkService.java
+++ b/src/java/com/android/internal/telephony/CellularNetworkService.java
@@ -16,7 +16,6 @@
 
 package com.android.internal.telephony;
 
-import android.annotation.CallSuper;
 import android.hardware.radio.V1_0.CellInfoType;
 import android.hardware.radio.V1_0.RegState;
 import android.os.AsyncResult;
@@ -277,7 +276,6 @@
                         accessNetworkTechnology, reasonForDenial, emergencyOnly, availableServices,
                         cellIdentity, maxDataCalls, false /* isDcNrRestricted */,
                         false /* isNrAvailable */, false /* isEnDcAvailable */);
-
             } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
                 android.hardware.radio.V1_2.DataRegStateResult dataRegState =
                         (android.hardware.radio.V1_2.DataRegStateResult) result;
@@ -506,10 +504,8 @@
             }
         }
 
-        @CallSuper
-        protected void onDestroy() {
-            super.onDestroy();
-
+        @Override
+        public void close() {
             mCallbackMap.clear();
             mHandlerThread.quit();
             mPhone.mCi.unregisterForNetworkStateChanged(mHandler);
diff --git a/src/java/com/android/internal/telephony/ImsSmsDispatcher.java b/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
index 70db301..2033d4a 100644
--- a/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
+++ b/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
@@ -179,7 +179,7 @@
                 int mappedResult;
                 switch (result) {
                     case Intents.RESULT_SMS_HANDLED:
-                        mappedResult = ImsSmsImplBase.STATUS_REPORT_STATUS_OK;
+                        mappedResult = ImsSmsImplBase.DELIVER_STATUS_OK;
                         break;
                     case Intents.RESULT_SMS_OUT_OF_MEMORY:
                         mappedResult = ImsSmsImplBase.DELIVER_STATUS_ERROR_NO_MEMORY;
@@ -199,11 +199,13 @@
                         Rlog.w(TAG, "SMS Received with a PDU that could not be parsed.");
                         getImsManager().acknowledgeSms(token, 0, mappedResult);
                     }
+                    mMetrics.writeImsServiceNewSms(mPhone.getPhoneId(), format, mappedResult);
                 } catch (ImsException e) {
                     Rlog.e(TAG, "Failed to acknowledgeSms(). Error: " + e.getMessage());
+                    mMetrics.writeImsServiceNewSms(mPhone.getPhoneId(), format,
+                            ImsSmsImplBase.DELIVER_STATUS_ERROR_GENERIC);
                 }
             }, true);
-            mMetrics.writeImsServiceNewSms(mPhone.getPhoneId(), format);
         }
     };
 
@@ -366,10 +368,13 @@
                     smsc != null ? new String(smsc) : null,
                     isRetry,
                     pdu);
-            mMetrics.writeImsServiceSendSms(mPhone.getPhoneId(), format);
+            mMetrics.writeImsServiceSendSms(mPhone.getPhoneId(), format,
+                    ImsSmsImplBase.SEND_STATUS_OK);
         } catch (ImsException e) {
             Rlog.e(TAG, "sendSms failed. Falling back to PSTN. Error: " + e.getMessage());
             fallbackToPstn(token, tracker);
+            mMetrics.writeImsServiceSendSms(mPhone.getPhoneId(), format,
+                    ImsSmsImplBase.SEND_STATUS_ERROR_FALLBACK);
         }
     }
 
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index eb10904..020a1c3 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -89,6 +89,7 @@
 import android.telephony.SmsManager;
 import android.telephony.TelephonyHistogram;
 import android.telephony.TelephonyManager;
+import android.telephony.data.ApnSetting;
 import android.telephony.data.DataProfile;
 import android.telephony.data.DataService;
 import android.text.TextUtils;
@@ -1256,8 +1257,8 @@
                 new android.hardware.radio.V1_4.DataProfileInfo();
 
         dpi.apn = dp.getApn();
-        dpi.protocol = dp.getProtocol();
-        dpi.roamingProtocol = dp.getRoamingProtocol();
+        dpi.protocol = ApnSetting.getProtocolIntFromString(dp.getProtocol());
+        dpi.roamingProtocol = ApnSetting.getProtocolIntFromString(dp.getRoamingProtocol());
         dpi.authType = dp.getAuthType();
         dpi.user = dp.getUserName();
         dpi.password = dp.getPassword();
diff --git a/src/java/com/android/internal/telephony/RcsController.java b/src/java/com/android/internal/telephony/RcsMessageStoreController.java
similarity index 72%
rename from src/java/com/android/internal/telephony/RcsController.java
rename to src/java/com/android/internal/telephony/RcsMessageStoreController.java
index e04b4b6..c2edd95 100644
--- a/src/java/com/android/internal/telephony/RcsController.java
+++ b/src/java/com/android/internal/telephony/RcsMessageStoreController.java
@@ -19,25 +19,26 @@
 import android.content.Context;
 import android.os.ServiceManager;
 import android.telephony.Rlog;
-import android.telephony.rcs.RcsManager;
+import android.telephony.ims.RcsMessageStore;
+import android.telephony.ims.aidl.IRcs;
 
 import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.telephony.rcs.IRcs;
 
-/** Backing implementation of {@link RcsManager}. */
-public class RcsController extends IRcs.Stub {
-    private static final String TAG = "RcsController";
+
+/** Backing implementation of {@link RcsMessageStore}. */
+public class RcsMessageStoreController extends IRcs.Stub {
+    private static final String TAG = "RcsMessageStoreController";
     private static final String RCS_SERVICE_NAME = "ircs";
 
-    private static RcsController sInstance;
+    private static RcsMessageStoreController sInstance;
 
     private final Context mContext;
 
     /** Initialize the instance. Should only be called once. */
-    public static RcsController init(Context context) {
-        synchronized (RcsController.class) {
+    public static RcsMessageStoreController init(Context context) {
+        synchronized (RcsMessageStoreController.class) {
             if (sInstance == null) {
-                sInstance = new RcsController(context);
+                sInstance = new RcsMessageStoreController(context);
             } else {
                 Rlog.e(TAG, "init() called multiple times! sInstance = " + sInstance);
             }
@@ -45,7 +46,7 @@
         return sInstance;
     }
 
-    private RcsController(Context context) {
+    private RcsMessageStoreController(Context context) {
         mContext = context;
         if (ServiceManager.getService(RCS_SERVICE_NAME) == null) {
             ServiceManager.addService(RCS_SERVICE_NAME, this);
@@ -53,7 +54,7 @@
     }
 
     @VisibleForTesting
-    public RcsController(Context context, Void unused) {
+    public RcsMessageStoreController(Context context, Void unused) {
         mContext = context;
     }
 
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index cd1f44a..3a5e9ad 100644
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -34,6 +34,7 @@
 import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.hardware.radio.V1_0.CellInfoType;
+import android.net.NetworkCapabilities;
 import android.os.AsyncResult;
 import android.os.BaseBundle;
 import android.os.Build;
@@ -50,6 +51,7 @@
 import android.provider.Settings;
 import android.telephony.AccessNetworkConstants;
 import android.telephony.AccessNetworkConstants.AccessNetworkType;
+import android.telephony.AccessNetworkConstants.TransportType;
 import android.telephony.CarrierConfigManager;
 import android.telephony.CellIdentity;
 import android.telephony.CellIdentityCdma;
@@ -82,6 +84,8 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
 import com.android.internal.telephony.cdma.EriInfo;
+import com.android.internal.telephony.dataconnection.DataConnection;
+import com.android.internal.telephony.dataconnection.DcTracker;
 import com.android.internal.telephony.dataconnection.TransportManager;
 import com.android.internal.telephony.metrics.TelephonyMetrics;
 import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
@@ -1439,9 +1443,16 @@
                     }
                     mPhone.notifyPhysicalChannelConfiguration(list);
                     mLastPhysicalChannelConfigList = list;
+                    boolean hasChanged =
+                            updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS);
+                    hasChanged |= updateNrStatusFromPhysicalChannelConfigs(
+                            list,
+                            mSS.getNetworkRegistrationState(
+                                    NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN));
 
-                    // only notify if bandwidths changed
-                    if (RatRatcheter.updateBandwidths(getBandwidthsFromConfigs(list), mSS)) {
+                    // Notify NR frequency, NR connection status or bandwidths changed.
+                    if (hasChanged
+                            || RatRatcheter.updateBandwidths(getBandwidthsFromConfigs(list), mSS)) {
                         mPhone.notifyServiceStateChanged(mSS);
                     }
                 }
@@ -1813,6 +1824,78 @@
         return cdmaRoaming && !isSameOperatorNameFromSimAndSS(s);
     }
 
+    private boolean isNrStatusChanged(
+            NetworkRegistrationState oldRegState, NetworkRegistrationState newRegState) {
+        if (oldRegState == null || newRegState == null) {
+            return oldRegState != newRegState;
+        }
+
+        return oldRegState.getNrStatus() != newRegState.getNrStatus();
+    }
+
+    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
+            List<PhysicalChannelConfig> physicalChannelConfigs, ServiceState ss) {
+        int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;
+
+        if (physicalChannelConfigs != null) {
+            DcTracker dcTracker = mPhone.getDcTracker(TransportType.WWAN);
+            for (PhysicalChannelConfig config : physicalChannelConfigs) {
+                if (isNrPhysicalChannelConfig(config)) {
+                    // Update the frequency range of the NR parameters if there is an internet data
+                    // connection associate to this NR physical channel channel config.
+                    int[] contextIds = config.getContextIds();
+                    for (int cid : contextIds) {
+                        DataConnection dc = dcTracker.getDataConnectionByContextId(cid);
+                        if (dc != null && dc.getNetworkCapabilities().hasCapability(
+                                NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
+                            newFrequencyRange = ServiceState.getBetterNRFrequencyRange(
+                                    newFrequencyRange, config.getFrequencyRange());
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        boolean hasChanged = newFrequencyRange != ss.getNrFrequencyRange();
+        ss.setNrFrequencyRange(newFrequencyRange);
+        return hasChanged;
+    }
+
+    private boolean updateNrStatusFromPhysicalChannelConfigs(
+            List<PhysicalChannelConfig> configs, NetworkRegistrationState regState) {
+
+        if (regState == null || configs == null) return false;
+
+        boolean hasNrSecondaryServingCell = false;
+        for (PhysicalChannelConfig config : configs) {
+            if (isNrPhysicalChannelConfig(config) && config.getConnectionStatus()
+                    == PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING) {
+                hasNrSecondaryServingCell = true;
+                break;
+            }
+        }
+
+        int newNrStatus = regState.getNrStatus();
+        if (hasNrSecondaryServingCell) {
+            if (regState.getNrStatus() == NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED) {
+                newNrStatus = NetworkRegistrationState.NR_STATUS_CONNECTED;
+            }
+        } else {
+            if (regState.getNrStatus() == NetworkRegistrationState.NR_STATUS_CONNECTED) {
+                newNrStatus = NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED;
+            }
+        }
+
+        boolean hasChanged = newNrStatus != regState.getNrStatus();
+        regState.setNrStatus(newNrStatus);
+        return hasChanged;
+    }
+
+    private boolean isNrPhysicalChannelConfig(PhysicalChannelConfig config) {
+        return config.getRat() == TelephonyManager.NETWORK_TYPE_NR;
+    }
+
     void handlePollStateResultMessage(int what, AsyncResult ar) {
         int ints[];
         switch (what) {
@@ -1905,14 +1988,17 @@
                         networkRegState.getAccessNetworkTechnology());
                 mNewSS.setDataRegState(serviceState);
                 mNewSS.setRilDataRadioTechnology(newDataRat);
-                mNewSS.addNetworkRegistrationState(networkRegState);
 
                 // When we receive OOS reset the PhyChanConfig list so that non-return-to-idle
                 // implementers of PhyChanConfig unsol will not carry forward a CA report
                 // (2 or more cells) to a new cell if they camp for emergency service only.
                 if (serviceState == ServiceState.STATE_OUT_OF_SERVICE) {
                     mLastPhysicalChannelConfigList = null;
+                    updateNrFrequencyRangeFromPhysicalChannelConfigs(null, mNewSS);
                 }
+                updateNrStatusFromPhysicalChannelConfigs(
+                        mLastPhysicalChannelConfigList, networkRegState);
+                mNewSS.addNetworkRegistrationState(networkRegState);
                 setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity());
 
                 if (mPhone.isPhoneTypeGsm()) {
@@ -2851,6 +2937,15 @@
         boolean hasVoiceRegStateChanged =
                 mSS.getVoiceRegState() != mNewSS.getVoiceRegState();
 
+        boolean hasNrFrequencyRangeChanged =
+                mSS.getNrFrequencyRange() != mNewSS.getNrFrequencyRange();
+
+        boolean hasNrStatusChanged = isNrStatusChanged(
+                mSS.getNetworkRegistrationState(
+                        NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN),
+                mNewSS.getNetworkRegistrationState(
+                        NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN));
+
         // TODO: loosen this restriction to exempt fields that are provided through system
         // information; otherwise, we will get false positives when things like the operator
         // alphas are provided later - that's better than missing location changes, but
@@ -2914,23 +3009,25 @@
 
         if (DBG) {
             log("pollStateDone:"
-                    + " hasRegistered=" + hasRegistered
-                    + " hasDeregistered=" + hasDeregistered
-                    + " hasDataAttached=" + hasDataAttached
-                    + " hasDataDetached=" + hasDataDetached
-                    + " hasDataRegStateChanged=" + hasDataRegStateChanged
-                    + " hasRilVoiceRadioTechnologyChanged= " + hasRilVoiceRadioTechnologyChanged
-                    + " hasRilDataRadioTechnologyChanged=" + hasRilDataRadioTechnologyChanged
-                    + " hasChanged=" + hasChanged
-                    + " hasVoiceRoamingOn=" + hasVoiceRoamingOn
-                    + " hasVoiceRoamingOff=" + hasVoiceRoamingOff
-                    + " hasDataRoamingOn=" + hasDataRoamingOn
-                    + " hasDataRoamingOff=" + hasDataRoamingOff
-                    + " hasLocationChanged=" + hasLocationChanged
+                    + " hasRegistered = " + hasRegistered
+                    + " hasDeregistered = " + hasDeregistered
+                    + " hasDataAttached = " + hasDataAttached
+                    + " hasDataDetached = " + hasDataDetached
+                    + " hasDataRegStateChanged = " + hasDataRegStateChanged
+                    + " hasRilVoiceRadioTechnologyChanged = " + hasRilVoiceRadioTechnologyChanged
+                    + " hasRilDataRadioTechnologyChanged = " + hasRilDataRadioTechnologyChanged
+                    + " hasChanged = " + hasChanged
+                    + " hasVoiceRoamingOn = " + hasVoiceRoamingOn
+                    + " hasVoiceRoamingOff = " + hasVoiceRoamingOff
+                    + " hasDataRoamingOn =" + hasDataRoamingOn
+                    + " hasDataRoamingOff = " + hasDataRoamingOff
+                    + " hasLocationChanged = " + hasLocationChanged
                     + " has4gHandoff = " + has4gHandoff
-                    + " hasMultiApnSupport=" + hasMultiApnSupport
-                    + " hasLostMultiApnSupport=" + hasLostMultiApnSupport
-                    + " hasCssIndicatorChanged=" + hasCssIndicatorChanged);
+                    + " hasMultiApnSupport = " + hasMultiApnSupport
+                    + " hasLostMultiApnSupport = " + hasLostMultiApnSupport
+                    + " hasCssIndicatorChanged = " + hasCssIndicatorChanged
+                    + " hasNrFrequencyRangeChanged = " + hasNrFrequencyRangeChanged
+                    + " hasNrStatusChanged = " + hasNrStatusChanged);
         }
 
         // Add an event log when connection state changes
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 09fcc93..5d45177 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -19,6 +19,7 @@
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
 
 import android.Manifest;
+import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.app.AppOpsManager;
 import android.app.PendingIntent;
@@ -1917,20 +1918,14 @@
      * @return the list of subId's that are active, is never null but the length maybe 0.
      */
     @Override
-    public int[] getActiveSubIdList() {
-        Set<Entry<Integer, Integer>> simInfoSet = new HashSet<>(sSlotIndexToSubId.entrySet());
-
-        int[] subIdArr = new int[simInfoSet.size()];
-        int i = 0;
-        for (Entry<Integer, Integer> entry: simInfoSet) {
-            int sub = entry.getValue();
-            subIdArr[i] = sub;
-            i++;
-        }
+    public @NonNull int[] getActiveSubIdList() {
+        int[] subIdArr = sSlotIndexToSubId.keySet().stream()
+                .sorted()
+                .mapToInt(slotId -> sSlotIndexToSubId.get(slotId))
+                .toArray();
 
         if (VDBG) {
-            logdl("[getActiveSubIdList] simInfoSet=" + simInfoSet + " subIdArr.length="
-                    + subIdArr.length);
+            logdl("[getActiveSubIdList] subIdArr=" + Arrays.toString(subIdArr));
         }
         return subIdArr;
     }
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
index e3c8cad..207a07a 100644
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
@@ -66,6 +66,8 @@
     private static final String LOG_TAG = "SubscriptionInfoUpdater";
     private static final int PROJECT_SIM_NUM = TelephonyManager.getDefault().getPhoneCount();
 
+    private static final boolean DBG = true;
+
     private static final int EVENT_INVALID = -1;
     private static final int EVENT_GET_NETWORK_SELECTION_MODE_DONE = 2;
     private static final int EVENT_SIM_LOADED = 3;
@@ -703,6 +705,7 @@
      */
     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
     public boolean updateEmbeddedSubscriptions() {
+        if (DBG) logd("updateEmbeddedSubscriptions");
         // Do nothing if eUICCs are disabled. (Previous entries may remain in the cache, but they
         // are filtered out of list calls as long as EuiccManager.isEnabled returns false).
         if (!mEuiccManager.isEnabled()) {
@@ -738,6 +741,8 @@
             embeddedIccids[i] = embeddedProfiles[i].getIccid();
         }
 
+        if (DBG) logd("Get eUICC profile list of size " + embeddedProfiles.length);
+
         // Note that this only tracks whether we make any writes to the DB. It's possible this will
         // be set to true for an update even when the row contents remain exactly unchanged from
         // before, since we don't compare against the previous value. Since this is only intended to
@@ -761,6 +766,12 @@
             } else {
                 existingSubscriptions.remove(index);
             }
+
+            if (DBG) {
+                logd("embeddedProfile " + embeddedProfile + " existing record "
+                        + (index < 0 ? "not found" : "found"));
+            }
+
             ContentValues values = new ContentValues();
             values.put(SubscriptionManager.IS_EMBEDDED, 1);
             List<UiccAccessRule> ruleList = embeddedProfile.getUiccAccessRules();
@@ -787,10 +798,15 @@
         // around in case the subscription is added back later, which is equivalent to a removable
         // SIM being removed and reinserted).
         if (!existingSubscriptions.isEmpty()) {
+            if (DBG) {
+                logd("Removing existing embedded subscriptions of size"
+                        + existingSubscriptions.size());
+            }
             List<String> iccidsToRemove = new ArrayList<>();
             for (int i = 0; i < existingSubscriptions.size(); i++) {
                 SubscriptionInfo info = existingSubscriptions.get(i);
                 if (info.isEmbedded()) {
+                    if (DBG) logd("Removing embedded subscription of IccId " + info.getIccId());
                     iccidsToRemove.add("\"" + info.getIccId() + "\"");
                 }
             }
@@ -805,6 +821,7 @@
             SubscriptionController.getInstance().refreshCachedActiveSubscriptionInfoList();
         }
 
+        if (DBG) logd("updateEmbeddedSubscriptions done hasChanges=" + hasChanges);
         return hasChanges;
     }
 
diff --git a/src/java/com/android/internal/telephony/dataconnection/CellularDataService.java b/src/java/com/android/internal/telephony/dataconnection/CellularDataService.java
index cbc3efe..555b6e9 100644
--- a/src/java/com/android/internal/telephony/dataconnection/CellularDataService.java
+++ b/src/java/com/android/internal/telephony/dataconnection/CellularDataService.java
@@ -69,6 +69,8 @@
 
         private final Handler mHandler;
 
+        private final HandlerThread mHandlerThread;
+
         private final Phone mPhone;
 
         private CellularDataServiceProvider(int slotId) {
@@ -76,9 +78,9 @@
 
             mPhone = PhoneFactory.getPhone(getSlotId());
 
-            HandlerThread thread = new HandlerThread(CellularDataService.class.getSimpleName());
-            thread.start();
-            mLooper = thread.getLooper();
+            mHandlerThread = new HandlerThread(CellularDataService.class.getSimpleName());
+            mHandlerThread.start();
+            mLooper = mHandlerThread.getLooper();
             mHandler = new Handler(mLooper) {
                 @Override
                 public void handleMessage(Message message) {
@@ -219,6 +221,12 @@
             }
             mPhone.mCi.getDataCallList(message);
         }
+
+        @Override
+        public void close() {
+            mPhone.mCi.unregisterForDataCallListChanged(mHandler);
+            mHandlerThread.quit();
+        }
     }
 
     @Override
diff --git a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
index e683c47..216ebb6 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
@@ -40,6 +40,7 @@
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.telephony.AccessNetworkConstants.TransportType;
+import android.telephony.DataFailCause;
 import android.telephony.Rlog;
 import android.telephony.ServiceState;
 import android.telephony.TelephonyManager;
@@ -173,14 +174,14 @@
     private ApnSetting mApnSetting;
     private ConnectionParams mConnectionParams;
     private DisconnectParams mDisconnectParams;
-    private DcFailCause mDcFailCause;
+    private DataFailCause mDcFailCause;
 
     private Phone mPhone;
     private DataServiceManager mDataServiceManager;
     private LinkProperties mLinkProperties = new LinkProperties();
     private long mCreateTime;
     private long mLastFailTime;
-    private DcFailCause mLastFailCause;
+    private DataFailCause mLastFailCause;
     private static final String NULL_IP = "0.0.0.0";
     private Object mUserData;
     private int mSubscriptionOverride;
@@ -349,10 +350,10 @@
         ERROR_STALE,
         ERROR_DATA_SERVICE_SPECIFIC_ERROR;
 
-        public DcFailCause mFailCause;
+        public DataFailCause mFailCause;
 
         SetupResult() {
-            mFailCause = DcFailCause.fromInt(0);
+            mFailCause = DataFailCause.fromInt(0);
         }
 
         @Override
@@ -530,7 +531,7 @@
 
         mCreateTime = -1;
         mLastFailTime = -1;
-        mLastFailCause = DcFailCause.NONE;
+        mLastFailCause = DataFailCause.NONE;
 
         Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
         msg.obj = cp;
@@ -609,7 +610,7 @@
     private void notifyAllOfDisconnectDcRetrying(String reason) {
         notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DC_RETRYING, reason);
     }
-    private void notifyAllDisconnectCompleted(DcFailCause cause) {
+    private void notifyAllDisconnectCompleted(DataFailCause cause) {
         notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, cause.toString());
     }
 
@@ -618,10 +619,10 @@
      * Send the connectionCompletedMsg.
      *
      * @param cp is the ConnectionParams
-     * @param cause and if no error the cause is DcFailCause.NONE
+     * @param cause and if no error the cause is DataFailCause.NONE
      * @param sendAll is true if all contexts are to be notified
      */
-    private void notifyConnectCompleted(ConnectionParams cp, DcFailCause cause, boolean sendAll) {
+    private void notifyConnectCompleted(ConnectionParams cp, DataFailCause cause, boolean sendAll) {
         ApnContext alreadySent = null;
 
         if (cp != null && cp.mOnCompletedMsg != null) {
@@ -633,7 +634,7 @@
             long timeStamp = System.currentTimeMillis();
             connectionCompletedMsg.arg1 = mCid;
 
-            if (cause == DcFailCause.NONE) {
+            if (cause == DataFailCause.NONE) {
                 mCreateTime = timeStamp;
                 AsyncResult.forMessage(connectionCompletedMsg);
             } else {
@@ -641,7 +642,7 @@
                 mLastFailTime = timeStamp;
 
                 // Return message with a Throwable exception to signify an error.
-                if (cause == null) cause = DcFailCause.UNKNOWN;
+                if (cause == null) cause = DataFailCause.UNKNOWN;
                 AsyncResult.forMessage(connectionCompletedMsg, cause,
                         new Throwable(cause.toString()));
             }
@@ -687,7 +688,7 @@
         }
         if (sendAll) {
             if (reason == null) {
-                reason = DcFailCause.UNKNOWN.toString();
+                reason = DataFailCause.UNKNOWN.toString();
             }
             notifyAllWithEvent(alreadySent, DctConstants.EVENT_DISCONNECT_DONE, reason);
         }
@@ -727,7 +728,7 @@
 
         mCreateTime = -1;
         mLastFailTime = -1;
-        mLastFailCause = DcFailCause.NONE;
+        mLastFailCause = DataFailCause.NONE;
         mCid = -1;
 
         mPcscfAddr = new String[5];
@@ -760,14 +761,14 @@
             result = SetupResult.ERROR_STALE;
         } else if (resultCode == DataServiceCallback.RESULT_ERROR_ILLEGAL_STATE) {
             result = SetupResult.ERROR_RADIO_NOT_AVAILABLE;
-            result.mFailCause = DcFailCause.RADIO_NOT_AVAILABLE;
+            result.mFailCause = DataFailCause.RADIO_NOT_AVAILABLE;
         } else if (response.getStatus() != 0) {
-            if (response.getStatus() == DcFailCause.RADIO_NOT_AVAILABLE.getErrorCode()) {
+            if (response.getStatus() == DataFailCause.RADIO_NOT_AVAILABLE.getErrorCode()) {
                 result = SetupResult.ERROR_RADIO_NOT_AVAILABLE;
-                result.mFailCause = DcFailCause.RADIO_NOT_AVAILABLE;
+                result.mFailCause = DataFailCause.RADIO_NOT_AVAILABLE;
             } else {
                 result = SetupResult.ERROR_DATA_SERVICE_SPECIFIC_ERROR;
-                result.mFailCause = DcFailCause.fromInt(response.getStatus());
+                result.mFailCause = DataFailCause.fromInt(response.getStatus());
             }
         } else {
             if (DBG) log("onSetupConnectionCompleted received successful DataCallResponse");
@@ -981,7 +982,10 @@
         return true;
     }
 
-    NetworkCapabilities getNetworkCapabilities() {
+    /**
+     * @return the {@link NetworkCapabilities} of this data connection.
+     */
+    public NetworkCapabilities getNetworkCapabilities() {
         NetworkCapabilities result = new NetworkCapabilities();
         result.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
 
@@ -1132,7 +1136,7 @@
         // a failure we'll clear again at the bottom of this code.
         linkProperties.clear();
 
-        if (response.getStatus() == DcFailCause.NONE.getErrorCode()) {
+        if (response.getStatus() == DataFailCause.NONE.getErrorCode()) {
             try {
                 // set interface name
                 linkProperties.setInterfaceName(response.getIfname());
@@ -1312,7 +1316,7 @@
                 case EVENT_CONNECT:
                     if (DBG) log("DcDefaultState: msg.what=EVENT_CONNECT, fail not expected");
                     ConnectionParams cp = (ConnectionParams) msg.obj;
-                    notifyConnectCompleted(cp, DcFailCause.UNKNOWN, false);
+                    notifyConnectCompleted(cp, DataFailCause.UNKNOWN, false);
                     break;
 
                 case EVENT_DISCONNECT:
@@ -1426,7 +1430,7 @@
      */
     private class DcInactiveState extends State {
         // Inform all contexts we've failed connecting
-        public void setEnterNotificationParams(ConnectionParams cp, DcFailCause cause) {
+        public void setEnterNotificationParams(ConnectionParams cp, DataFailCause cause) {
             if (VDBG) log("DcInactiveState: setEnterNotificationParams cp,cause");
             mConnectionParams = cp;
             mDisconnectParams = null;
@@ -1438,11 +1442,11 @@
             if (VDBG) log("DcInactiveState: setEnterNotificationParams dp");
             mConnectionParams = null;
             mDisconnectParams = dp;
-            mDcFailCause = DcFailCause.NONE;
+            mDcFailCause = DataFailCause.NONE;
         }
 
         // Inform all contexts of the failure cause
-        public void setEnterNotificationParams(DcFailCause cause) {
+        public void setEnterNotificationParams(DataFailCause cause) {
             mConnectionParams = null;
             mDisconnectParams = null;
             mDcFailCause = cause;
@@ -1515,7 +1519,7 @@
                         if (DBG) {
                             log("DcInactiveState: msg.what=EVENT_CONNECT initConnection failed");
                         }
-                        notifyConnectCompleted(cp, DcFailCause.UNACCEPTABLE_NETWORK_PARAMETER,
+                        notifyConnectCompleted(cp, DataFailCause.UNACCEPTABLE_NETWORK_PARAMETER,
                                 false);
                     }
                     retVal = HANDLED;
@@ -1595,7 +1599,7 @@
                     switch (result) {
                         case SUCCESS:
                             // All is well
-                            mDcFailCause = DcFailCause.NONE;
+                            mDcFailCause = DataFailCause.NONE;
                             transitionTo(mActiveState);
                             break;
                         case ERROR_RADIO_NOT_AVAILABLE:
@@ -1759,7 +1763,7 @@
                     if (DBG) {
                         log("DcActiveState: EVENT_CONNECT cp=" + cp + " dc=" + DataConnection.this);
                     }
-                    notifyConnectCompleted(cp, DcFailCause.NONE, false);
+                    notifyConnectCompleted(cp, DataFailCause.NONE, false);
                     retVal = HANDLED;
                     break;
                 }
@@ -1813,7 +1817,7 @@
                         log("DcActiveState EVENT_LOST_CONNECTION dc=" + DataConnection.this);
                     }
 
-                    mInactiveState.setEnterNotificationParams(DcFailCause.LOST_CONNECTION);
+                    mInactiveState.setEnterNotificationParams(DataFailCause.LOST_CONNECTION);
                     transitionTo(mInactiveState);
                     retVal = HANDLED;
                     break;
@@ -2101,7 +2105,7 @@
                         // Transition to inactive but send notifications after
                         // we've entered the mInactive state.
                         mInactiveState.setEnterNotificationParams(cp,
-                                DcFailCause.UNACCEPTABLE_NETWORK_PARAMETER);
+                                DataFailCause.UNACCEPTABLE_NETWORK_PARAMETER);
                         transitionTo(mInactiveState);
                     } else {
                         if (DBG) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcController.java b/src/java/com/android/internal/telephony/dataconnection/DcController.java
index 2f74ff0..8933f8b 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcController.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcController.java
@@ -27,6 +27,7 @@
 import android.os.Handler;
 import android.os.Message;
 import android.telephony.AccessNetworkConstants.TransportType;
+import android.telephony.DataFailCause;
 import android.telephony.PhoneStateListener;
 import android.telephony.Rlog;
 import android.telephony.TelephonyManager;
@@ -330,7 +331,7 @@
                             apnsToCleanup.addAll(apnContexts);
                             mDct.isCleanupRequired.set(false);
                         } else {
-                            DcFailCause failCause = DcFailCause.fromInt(newState.getStatus());
+                            DataFailCause failCause = DataFailCause.fromInt(newState.getStatus());
                             if (failCause.isRadioRestartFailure(mPhone.getContext(),
                                         mPhone.getSubId())) {
                                 if (DBG) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java b/src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java
index c24d0bf..b6a63cf 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java
@@ -17,6 +17,7 @@
 package com.android.internal.telephony.dataconnection;
 
 import android.content.Intent;
+import android.telephony.DataFailCause;
 import android.telephony.Rlog;
 
 /**
@@ -39,8 +40,8 @@
 
     // failCause with its --ei option name and default value
     static final String FAIL_CAUSE = "fail_cause";
-    static final DcFailCause DEFAULT_FAIL_CAUSE = DcFailCause.ERROR_UNSPECIFIED;
-    DcFailCause mFailCause;
+    static final DataFailCause DEFAULT_FAIL_CAUSE = DataFailCause.ERROR_UNSPECIFIED;
+    DataFailCause mFailCause;
 
     // suggestedRetryTime with its --ei option name and default value
     static final String SUGGESTED_RETRY_TIME = "suggested_retry_time";
@@ -51,7 +52,7 @@
     void saveParameters(Intent intent, String s) {
         if (DBG) log(s + ".saveParameters: action=" + intent.getAction());
         mCounter = intent.getIntExtra(COUNTER, DEFAULT_COUNTER);
-        mFailCause = DcFailCause.fromInt(
+        mFailCause = DataFailCause.fromInt(
                 intent.getIntExtra(FAIL_CAUSE, DEFAULT_FAIL_CAUSE.getErrorCode()));
         mSuggestedRetryTime =
                 intent.getIntExtra(SUGGESTED_RETRY_TIME, DEFAULT_SUGGESTED_RETRY_TIME);
@@ -62,7 +63,7 @@
 
     public void saveParameters(int counter, int failCause, int suggestedRetryTime) {
         mCounter = counter;
-        mFailCause = DcFailCause.fromInt(failCause);
+        mFailCause = DataFailCause.fromInt(failCause);
         mSuggestedRetryTime = suggestedRetryTime;
     }
 
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcFailCause.java b/src/java/com/android/internal/telephony/dataconnection/DcFailCause.java
deleted file mode 100644
index 79c79de..0000000
--- a/src/java/com/android/internal/telephony/dataconnection/DcFailCause.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.internal.telephony.dataconnection;
-
-import android.content.Context;
-import android.os.PersistableBundle;
-import android.telephony.CarrierConfigManager;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-
-/**
- * Returned as the reason for a connection failure as defined
- * by RIL_DataCallFailCause in ril.h and some local errors.
- */
-public enum DcFailCause {
-    NONE(0),
-
-    // This series of errors as specified by the standards
-    // specified in ril.h
-    OPERATOR_BARRED(0x08),                  /* no retry */
-    NAS_SIGNALLING(0x0E),
-    LLC_SNDCP(0x19),
-    INSUFFICIENT_RESOURCES(0x1A),
-    MISSING_UNKNOWN_APN(0x1B),              /* no retry */
-    UNKNOWN_PDP_ADDRESS_TYPE(0x1C),         /* no retry */
-    USER_AUTHENTICATION(0x1D),              /* no retry */
-    ACTIVATION_REJECT_GGSN(0x1E),           /* no retry */
-    ACTIVATION_REJECT_UNSPECIFIED(0x1F),
-    SERVICE_OPTION_NOT_SUPPORTED(0x20),     /* no retry */
-    SERVICE_OPTION_NOT_SUBSCRIBED(0x21),    /* no retry */
-    SERVICE_OPTION_OUT_OF_ORDER(0x22),
-    NSAPI_IN_USE(0x23),                     /* no retry */
-    REGULAR_DEACTIVATION(0x24),             /* possibly restart radio, based on config */
-    QOS_NOT_ACCEPTED(0x25),
-    NETWORK_FAILURE(0x26),
-    UMTS_REACTIVATION_REQ(0x27),
-    FEATURE_NOT_SUPP(0x28),
-    TFT_SEMANTIC_ERROR(0x29),
-    TFT_SYTAX_ERROR(0x2A),
-    UNKNOWN_PDP_CONTEXT(0x2B),
-    FILTER_SEMANTIC_ERROR(0x2C),
-    FILTER_SYTAX_ERROR(0x2D),
-    PDP_WITHOUT_ACTIVE_TFT(0x2E),
-    ONLY_IPV4_ALLOWED(0x32),                /* no retry */
-    ONLY_IPV6_ALLOWED(0x33),                /* no retry */
-    ONLY_SINGLE_BEARER_ALLOWED(0x34),
-    ESM_INFO_NOT_RECEIVED(0x35),
-    PDN_CONN_DOES_NOT_EXIST(0x36),
-    MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED(0x37),
-    MAX_ACTIVE_PDP_CONTEXT_REACHED(0x41),
-    UNSUPPORTED_APN_IN_CURRENT_PLMN(0x42),
-    INVALID_TRANSACTION_ID(0x51),
-    MESSAGE_INCORRECT_SEMANTIC(0x5F),
-    INVALID_MANDATORY_INFO(0x60),
-    MESSAGE_TYPE_UNSUPPORTED(0x61),
-    MSG_TYPE_NONCOMPATIBLE_STATE(0x62),
-    UNKNOWN_INFO_ELEMENT(0x63),
-    CONDITIONAL_IE_ERROR(0x64),
-    MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE(0x65),
-    PROTOCOL_ERRORS(0x6F),                  /* no retry */
-    APN_TYPE_CONFLICT(0x70),
-    INVALID_PCSCF_ADDR(0x71),
-    INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN(0x72),
-    EMM_ACCESS_BARRED(0x73),
-    EMERGENCY_IFACE_ONLY(0x74),
-    IFACE_MISMATCH(0x75),
-    COMPANION_IFACE_IN_USE(0x76),
-    IP_ADDRESS_MISMATCH(0x77),
-    IFACE_AND_POL_FAMILY_MISMATCH(0x78),
-    EMM_ACCESS_BARRED_INFINITE_RETRY(0x79),
-    AUTH_FAILURE_ON_EMERGENCY_CALL(0x7A),
-
-    // OEM sepecific error codes. To be used by OEMs when they don't
-    // want to reveal error code which would be replaced by ERROR_UNSPECIFIED
-    OEM_DCFAILCAUSE_1(0x1001),
-    OEM_DCFAILCAUSE_2(0x1002),
-    OEM_DCFAILCAUSE_3(0x1003),
-    OEM_DCFAILCAUSE_4(0x1004),
-    OEM_DCFAILCAUSE_5(0x1005),
-    OEM_DCFAILCAUSE_6(0x1006),
-    OEM_DCFAILCAUSE_7(0x1007),
-    OEM_DCFAILCAUSE_8(0x1008),
-    OEM_DCFAILCAUSE_9(0x1009),
-    OEM_DCFAILCAUSE_10(0x100A),
-    OEM_DCFAILCAUSE_11(0x100B),
-    OEM_DCFAILCAUSE_12(0x100C),
-    OEM_DCFAILCAUSE_13(0x100D),
-    OEM_DCFAILCAUSE_14(0x100E),
-    OEM_DCFAILCAUSE_15(0x100F),
-
-    // Local errors generated by Vendor RIL
-    // specified in ril.h
-    REGISTRATION_FAIL(-1),
-    GPRS_REGISTRATION_FAIL(-2),
-    SIGNAL_LOST(-3),                        /* no retry */
-    PREF_RADIO_TECH_CHANGED(-4),
-    RADIO_POWER_OFF(-5),                    /* no retry */
-    TETHERED_CALL_ACTIVE(-6),               /* no retry */
-    ERROR_UNSPECIFIED(0xFFFF),
-
-    // Errors generated by the Framework
-    // specified here
-    UNKNOWN(0x10000),
-    RADIO_NOT_AVAILABLE(0x10001),                   /* no retry */
-    UNACCEPTABLE_NETWORK_PARAMETER(0x10002),        /* no retry */
-    CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003),
-    LOST_CONNECTION(0x10004),
-    RESET_BY_FRAMEWORK(0x10005);
-
-    private final int mErrorCode;
-    private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap;
-    static {
-        sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>();
-        for (DcFailCause fc : values()) {
-            sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc);
-        }
-    }
-
-    /**
-     * Map of subId -> set of data call setup permanent failure for the carrier.
-     */
-    private static final HashMap<Integer, HashSet<DcFailCause>> sPermanentFailureCache =
-            new HashMap<>();
-
-    DcFailCause(int errorCode) {
-        mErrorCode = errorCode;
-    }
-
-    public int getErrorCode() {
-        return mErrorCode;
-    }
-
-    /**
-     * Returns whether or not the fail cause is a failure that requires a modem restart
-     *
-     * @param context device context
-     * @param subId subscription index
-     * @return true if the fail cause code needs platform to trigger a modem restart.
-     */
-    public boolean isRadioRestartFailure(Context context, int subId) {
-        CarrierConfigManager configManager = (CarrierConfigManager)
-                context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
-        if (configManager != null) {
-            PersistableBundle b = configManager.getConfigForSubId(subId);
-
-            if (b != null) {
-                if (this == REGULAR_DEACTIVATION
-                        && b.getBoolean(CarrierConfigManager
-                        .KEY_RESTART_RADIO_ON_PDP_FAIL_REGULAR_DEACTIVATION_BOOL)) {
-                    // This is for backward compatibility support. We need to continue support this
-                    // old configuration until it gets removed in the future.
-                    return true;
-                }
-                // Check the current configurations.
-                int[] causeCodes = b.getIntArray(CarrierConfigManager
-                        .KEY_RADIO_RESTART_FAILURE_CAUSES_INT_ARRAY);
-                if (causeCodes != null) {
-                    return Arrays.stream(causeCodes).anyMatch(i -> i == getErrorCode());
-                }
-            }
-        }
-
-        return false;
-    }
-
-    public boolean isPermanentFailure(Context context, int subId) {
-
-        synchronized (sPermanentFailureCache) {
-
-            HashSet<DcFailCause> permanentFailureSet = sPermanentFailureCache.get(subId);
-
-            // In case of cache miss, we need to look up the settings from carrier config.
-            if (permanentFailureSet == null) {
-                // Retrieve the permanent failure from carrier config
-                CarrierConfigManager configManager = (CarrierConfigManager)
-                        context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
-                if (configManager != null) {
-                    PersistableBundle b = configManager.getConfigForSubId(subId);
-                    if (b != null) {
-                        String[] permanentFailureStrings = b.getStringArray(CarrierConfigManager.
-                                KEY_CARRIER_DATA_CALL_PERMANENT_FAILURE_STRINGS);
-
-                        if (permanentFailureStrings != null) {
-                            permanentFailureSet = new HashSet<>();
-                            for (String failure : permanentFailureStrings) {
-                                permanentFailureSet.add(DcFailCause.valueOf(failure));
-                            }
-                        }
-                    }
-                }
-
-                // If we are not able to find the configuration from carrier config, use the default
-                // ones.
-                if (permanentFailureSet == null) {
-                    permanentFailureSet = new HashSet<DcFailCause>() {
-                        {
-                            add(OPERATOR_BARRED);
-                            add(MISSING_UNKNOWN_APN);
-                            add(UNKNOWN_PDP_ADDRESS_TYPE);
-                            add(USER_AUTHENTICATION);
-                            add(ACTIVATION_REJECT_GGSN);
-                            add(SERVICE_OPTION_NOT_SUPPORTED);
-                            add(SERVICE_OPTION_NOT_SUBSCRIBED);
-                            add(NSAPI_IN_USE);
-                            add(ONLY_IPV4_ALLOWED);
-                            add(ONLY_IPV6_ALLOWED);
-                            add(PROTOCOL_ERRORS);
-                            add(RADIO_POWER_OFF);
-                            add(TETHERED_CALL_ACTIVE);
-                            add(RADIO_NOT_AVAILABLE);
-                            add(UNACCEPTABLE_NETWORK_PARAMETER);
-                            add(SIGNAL_LOST);
-                        }
-                    };
-                }
-
-                sPermanentFailureCache.put(subId, permanentFailureSet);
-            }
-
-            return permanentFailureSet.contains(this);
-        }
-    }
-
-    public boolean isEventLoggable() {
-        return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) ||
-                (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) ||
-                (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) ||
-                (this == SERVICE_OPTION_NOT_SUBSCRIBED) ||
-                (this == SERVICE_OPTION_NOT_SUPPORTED) ||
-                (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) ||
-                (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
-                (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) ||
-                (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) ||
-                (this == UNACCEPTABLE_NETWORK_PARAMETER);
-    }
-
-    public static DcFailCause fromInt(int errorCode) {
-        DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode);
-        if (fc == null) {
-            fc = UNKNOWN;
-        }
-        return fc;
-    }
-}
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTesterFailBringUpAll.java b/src/java/com/android/internal/telephony/dataconnection/DcTesterFailBringUpAll.java
index dede71e..25edbe1 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTesterFailBringUpAll.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTesterFailBringUpAll.java
@@ -22,6 +22,7 @@
 import android.content.IntentFilter;
 import android.os.Build;
 import android.os.Handler;
+import android.telephony.DataFailCause;
 import android.telephony.Rlog;
 
 import com.android.internal.telephony.Phone;
@@ -35,7 +36,7 @@
  * Also you can add a suggested retry time if desired:
  *     --ei suggested_retry_time 5000
  *
- * The fail_cause is one of {@link DcFailCause}
+ * The fail_cause is one of {@link DataFailCause}
  */
 public class DcTesterFailBringUpAll {
     private static final String LOG_TAG = "DcTesterFailBrinupAll";
@@ -61,12 +62,12 @@
                 // Counter is MAX, bringUp/retry will always fail
                 log("simulate detaching");
                 mFailBringUp.saveParameters(Integer.MAX_VALUE,
-                        DcFailCause.LOST_CONNECTION.getErrorCode(),
+                        DataFailCause.LOST_CONNECTION.getErrorCode(),
                         DcFailBringUp.DEFAULT_SUGGESTED_RETRY_TIME);
             } else if (action.equals(mPhone.getActionAttached())) {
                 // Counter is 0 next bringUp/retry will succeed
                 log("simulate attaching");
-                mFailBringUp.saveParameters(0, DcFailCause.NONE.getErrorCode(),
+                mFailBringUp.saveParameters(0, DataFailCause.NONE.getErrorCode(),
                         DcFailBringUp.DEFAULT_SUGGESTED_RETRY_TIME);
             } else {
                 if (DBG) log("onReceive: unknown action=" + action);
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
index ca85e33..f22acc0 100755
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -62,6 +62,7 @@
 import android.telephony.AccessNetworkConstants.TransportType;
 import android.telephony.CarrierConfigManager;
 import android.telephony.CellLocation;
+import android.telephony.DataFailCause;
 import android.telephony.PcoData;
 import android.telephony.Rlog;
 import android.telephony.ServiceState;
@@ -1429,7 +1430,7 @@
                 ArrayList<ApnSetting> waitingApns =
                         buildWaitingApns(apnContext.getApnType(), radioTech);
                 if (waitingApns.isEmpty()) {
-                    notifyNoData(DcFailCause.MISSING_UNKNOWN_APN, apnContext);
+                    notifyNoData(DataFailCause.MISSING_UNKNOWN_APN, apnContext);
                     notifyOffApnsOfAvailability(apnContext.getReason());
                     String str = "trySetupData: X No APN found retValue=false";
                     if (DBG) log(str);
@@ -1763,6 +1764,13 @@
     }
 
     /**
+     * @return the {@link DataConnection} with the given context id {@code cid}.
+     */
+    public DataConnection getDataConnectionByContextId(int cid) {
+        return mDcc.getActiveDcByCid(cid);
+    }
+
+    /**
      * Determine if DUN connection is special and we need to teardown on start/stop
      */
     private boolean teardownForDun() {
@@ -1792,9 +1800,9 @@
         }
     }
 
-    boolean isPermanentFailure(DcFailCause dcFailCause) {
+    boolean isPermanentFailure(DataFailCause dcFailCause) {
         return (dcFailCause.isPermanentFailure(mPhone.getContext(), mPhone.getSubId()) &&
-                (mAttached.get() == false || dcFailCause != DcFailCause.SIGNAL_LOST));
+                (mAttached.get() == false || dcFailCause != DataFailCause.SIGNAL_LOST));
     }
 
     private DataConnection findFreeDataConnection() {
@@ -2134,7 +2142,7 @@
                 SystemClock.elapsedRealtime() + delay, alarmIntent);
     }
 
-    private void notifyNoData(DcFailCause lastFailCauseCode,
+    private void notifyNoData(DataFailCause lastFailCauseCode,
                               ApnContext apnContext) {
         if (DBG) log( "notifyNoData: type=" + apnContext.getApnType());
         if (isPermanentFailure(lastFailCauseCode)
@@ -2715,7 +2723,7 @@
      */
     private void onDataSetupComplete(AsyncResult ar) {
 
-        DcFailCause cause = DcFailCause.UNKNOWN;
+        DataFailCause cause = DataFailCause.UNKNOWN;
         boolean handleError = false;
         ApnContext apnContext = getValidApnContext(ar, "onDataSetupComplete");
 
@@ -2744,7 +2752,7 @@
             }
             if (dataConnection == null) {
                 log("onDataSetupComplete: no connection to DC, handle as error");
-                cause = DcFailCause.CONNECTION_TO_DATACONNECTIONAC_BROKEN;
+                cause = DataFailCause.CONNECTION_TO_DATACONNECTIONAC_BROKEN;
                 handleError = true;
             } else {
                 ApnSetting apn = apnContext.getApnSetting();
@@ -2856,7 +2864,7 @@
                 }
             }
         } else {
-            cause = (DcFailCause) (ar.result);
+            cause = (DataFailCause) (ar.result);
             if (DBG) {
                 ApnSetting apn = apnContext.getApnSetting();
                 log(String.format("onDataSetupComplete: error apn=%s cause=%s",
diff --git a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
index 97a6817..47844ca 100644
--- a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
+++ b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
@@ -38,6 +38,7 @@
 import android.hardware.radio.V1_0.SetupDataCallResult;
 import android.os.Build;
 import android.os.SystemClock;
+import android.os.SystemProperties;
 import android.telephony.Rlog;
 import android.telephony.ServiceState;
 import android.telephony.SmsManager;
@@ -422,6 +423,19 @@
                 pw.print(event.delay);
                 pw.print(" T=");
                 pw.println(smsSessionEventToString(event.type));
+                // Only show more info for tx/rx sms
+                if (event.type == SmsSession.Event.Type.SMS_SEND
+                        || event.type == SmsSession.Event.Type.SMS_RECEIVED
+                        || event.type == SmsSession.Event.Type.SMS_SEND_RESULT) {
+                    pw.print(" ReqId=");
+                    pw.println(event.rilRequestId);
+                    pw.print(" E=");
+                    pw.println(event.errorCode);
+                    pw.print(" RilE=");
+                    pw.println(event.error);
+                    pw.print(" ImsE=");
+                    pw.println(event.imsError);
+                }
             }
             pw.decreaseIndent();
         }
@@ -450,6 +464,7 @@
                 + "rx signal strength levels (ms): "
                 + Arrays.toString(s.timeInRxSignalStrengthLevelMs));
         pw.decreaseIndent();
+        pw.println("Hardware Version: " + SystemProperties.get("ro.boot.revision", ""));
     }
 
     /**
@@ -546,6 +561,9 @@
         // Build modem power metrics
         log.modemPowerStats = new ModemPowerMetrics().buildProto();
 
+        // Log the hardware revision
+        log.hardwareRevision = SystemProperties.get("ro.boot.revision", "");
+
         // Log the starting system time
         log.startTime = new TelephonyProto.Time();
         log.startTime.systemTimestampMillis = mStartSystemTimeMs;
@@ -1484,7 +1502,7 @@
         } else {
 
             smsSession.addEvent(new SmsSessionEventBuilder(
-                    SmsSession.Event.Type.SMS_SEND_RESULT_IMS_SERVICE)
+                    SmsSession.Event.Type.SMS_SEND_RESULT)
                     .setImsServiceErrno(resultCode)
                     .setErrorCode(errorReason)
             );
@@ -1784,9 +1802,12 @@
      *
      * @param phoneId Phone id
      * @param format SMS format. Either {@link SmsMessage#FORMAT_3GPP} or
-     * {@link SmsMessage#FORMAT_3GPP2}.
+     *         {@link SmsMessage#FORMAT_3GPP2}.
+     * @param resultCode The result of sending the new SMS to the vendor layer to be sent to the
+     *         carrier network.
      */
-    public synchronized void writeImsServiceSendSms(int phoneId, String format) {
+    public synchronized void writeImsServiceSendSms(int phoneId, String format,
+            @ImsSmsImplBase.SendStatusResult int resultCode) {
         InProgressSmsSession smsSession = startNewSmsSessionIfNeeded(phoneId);
         int formatCode = SmsSession.Event.Format.SMS_FORMAT_UNKNOWN;
         switch (format) {
@@ -1799,8 +1820,9 @@
                 break;
             }
         }
-        smsSession.addEvent(new SmsSessionEventBuilder(SmsSession.Event.Type.SMS_SEND_IMS_SERVICE)
+        smsSession.addEvent(new SmsSessionEventBuilder(SmsSession.Event.Type.SMS_SEND)
                 .setTech(SmsSession.Event.Tech.SMS_IMS)
+                .setImsServiceErrno(resultCode)
                 .setFormat(formatCode)
         );
 
@@ -1831,8 +1853,10 @@
      * @param phoneId Phone id
      * @param format SMS format. Either {@link SmsMessage#FORMAT_3GPP} or
      * {@link SmsMessage#FORMAT_3GPP2}.
+     * @param result The result of processing the the newly received SMS message.
      */
-    public synchronized void writeImsServiceNewSms(int phoneId, String format) {
+    public synchronized void writeImsServiceNewSms(int phoneId, String format,
+            @ImsSmsImplBase.DeliverStatusResult int result) {
         InProgressSmsSession smsSession = startNewSmsSessionIfNeeded(phoneId);
         int formatCode = SmsSession.Event.Format.SMS_FORMAT_UNKNOWN;
         switch (format) {
@@ -1845,10 +1869,31 @@
                 break;
             }
         }
+        int smsError = SmsManager.RESULT_ERROR_GENERIC_FAILURE;
+        switch (result) {
+            case ImsSmsImplBase.DELIVER_STATUS_OK: {
+                smsError = SmsManager.RESULT_ERROR_NONE;
+                break;
+            }
+            case ImsSmsImplBase.DELIVER_STATUS_ERROR_NO_MEMORY: {
+                smsError = SmsManager.RESULT_NO_MEMORY;
+                break;
+            }
+            case ImsSmsImplBase.DELIVER_STATUS_ERROR_REQUEST_NOT_SUPPORTED: {
+                smsError = SmsManager.RESULT_REQUEST_NOT_SUPPORTED;
+                break;
+            }
+            case ImsSmsImplBase.DELIVER_STATUS_ERROR_GENERIC: {
+                smsError = SmsManager.RESULT_ERROR_GENERIC_FAILURE;
+                break;
+            }
+        }
         smsSession.addEvent(new SmsSessionEventBuilder(
-                SmsSession.Event.Type.SMS_RECEIVED_IMS_SERVICE)
+                SmsSession.Event.Type.SMS_RECEIVED)
                 .setTech(SmsSession.Event.Tech.SMS_IMS)
                 .setFormat(formatCode)
+                .setErrorCode(smsError)
+                .setImsServiceErrno(TelephonyProto.ImsServiceErrno.IMS_E_SUCCESS)
         );
 
         finishSmsSessionIfNeeded(smsSession);
@@ -1863,9 +1908,12 @@
      * @param isCMAS true if msg is CMAS
      * @param isETWS true if msg is ETWS
      * @param serviceCategory Service category of CB msg
+     * @param serialNumber Serial number of the message
+     * @param deliveredTimestamp Message's delivered timestamp
      */
     public synchronized void writeNewCBSms(int phoneId, int format, int priority, boolean isCMAS,
-                                           boolean isETWS, int serviceCategory) {
+                                           boolean isETWS, int serviceCategory, int serialNumber,
+                                           long deliveredTimestamp) {
         InProgressSmsSession smsSession = startNewSmsSessionIfNeeded(phoneId);
 
         int type;
@@ -1882,6 +1930,8 @@
         cbm.msgPriority = priority + 1;
         cbm.msgType = type;
         cbm.serviceCategory = serviceCategory;
+        cbm.serialNumber = serialNumber;
+        cbm.deliveredTimestampMillis = deliveredTimestamp;
 
         smsSession.addEvent(new SmsSessionEventBuilder(SmsSession.Event.Type.CB_SMS_RECEIVED)
                 .setCellBroadcastMessage(cbm)
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
index 61b0077..2d1b5c2 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java
@@ -45,6 +45,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 
+import java.util.Arrays;
 import java.util.List;
 
 public class SubscriptionControllerTest extends TelephonyTest {
@@ -522,4 +523,15 @@
         doReturn(mTelephonyRegisteryMock).when(mTelephonyRegisteryMock)
                 .queryLocalInterface(anyString());
     }
+
+    @Test
+    @SmallTest
+    public void testGetActiveSubIdList() throws Exception {
+        mSubscriptionControllerUT.addSubInfoRecord("123", 1);   // sub 1
+        mSubscriptionControllerUT.addSubInfoRecord("456", 0);   // sub 2
+
+        // Make sure the return sub ids are sorted by slot index
+        assertTrue("active sub ids = " + mSubscriptionControllerUT.getActiveSubIdList(),
+                Arrays.equals(mSubscriptionControllerUT.getActiveSubIdList(), new int[]{2, 1}));
+    }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java
index b7b8d83..8893742 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java
@@ -292,9 +292,9 @@
                 null, null, -1, "user", "password", 0,
                 ApnSetting.TYPE_DEFAULT, ApnSetting.PROTOCOL_IPV6, ApnSetting.PROTOCOL_IP, true,
                 4096, 0, false, 0, 0, 0, 0, ApnSetting.MVNO_TYPE_SPN, "");
-        String expected = "[ApnSettingV5] Name, 99, 12345, apn, null, "
+        String expected = "[ApnSettingV6] Name, 99, 12345, apn, null, "
                 + "null, null, null, 10, 0, default, "
-                + "IPV6, IP, true, 0, false, 0, 0, 0, 0, spn, , false, 4096, 0";
+                + "IPV6, IP, true, 0, false, 0, 0, 0, 0, spn, , false, 4096, 0, -1";
         assertEquals(expected, apn.toString());
 
         final int networkTypeBitmask = 1 << (14 - 1);
@@ -303,9 +303,9 @@
                 null, null, -1, "user", "password", 0,
                 ApnSetting.TYPE_DEFAULT, ApnSetting.PROTOCOL_IPV6, ApnSetting.PROTOCOL_IP, true,
                 networkTypeBitmask, 0, false, 0, 0, 0, 0, ApnSetting.MVNO_TYPE_SPN, "", 3, -1);
-        expected = "[ApnSettingV5] Name, 99, 12345, apn, null, "
+        expected = "[ApnSettingV6] Name, 99, 12345, apn, null, "
                 + "null, null, null, 10, 0, default, "
-                + "IPV6, IP, true, 0, false, 0, 0, 0, 0, spn, , false, 8192, 3";
+                + "IPV6, IP, true, 0, false, 0, 0, 0, 0, spn, , false, 8192, 3, -1";
         assertEquals(expected, apn.toString());
     }
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcFailCauseTest.java b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcFailCauseTest.java
index 48fc139..e0deb63 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcFailCauseTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcFailCauseTest.java
@@ -25,6 +25,7 @@
 import android.content.Context;
 import android.os.PersistableBundle;
 import android.telephony.CarrierConfigManager;
+import android.telephony.DataFailCause;
 import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.internal.telephony.TelephonyTest;
@@ -161,10 +162,11 @@
     @SmallTest
     public void testPermanentFailDefault() throws Exception {
         for (DcFailCauseData data : mFailCauseDataList) {
-            assertEquals("cause = " + data.mCause, data.mPermanentFailure, DcFailCause.fromInt(
+            assertEquals("cause = " + data.mCause, data.mPermanentFailure,
+                    DataFailCause.fromInt(
                     data.mCause).isPermanentFailure(mContext, mPhone.getSubId()));
         }
-        assertFalse(DcFailCause.fromInt(123456).isPermanentFailure(mContext, mPhone.getSubId()));
+        assertFalse(DataFailCause.fromInt(123456).isPermanentFailure(mContext, mPhone.getSubId()));
     }
 
     @Test
@@ -180,13 +182,16 @@
         // Run it twice to make sure the cached carrier config is working as expected.
         for (int i = 0; i < 2; i++) {
             for (DcFailCauseData data : mFailCauseDataList) {
-                if (DcFailCause.fromInt(data.mCause).equals(
-                        DcFailCause.SERVICE_OPTION_NOT_SUBSCRIBED) ||
-                        DcFailCause.fromInt(data.mCause).equals(DcFailCause.TETHERED_CALL_ACTIVE)) {
-                    assertTrue("cause = " + data.mCause, DcFailCause.fromInt(data.mCause).
+                if (DataFailCause.fromInt(data.mCause).equals(
+                        DataFailCause.SERVICE_OPTION_NOT_SUBSCRIBED) ||
+                        DataFailCause.fromInt(data.mCause).equals(
+                                DataFailCause.TETHERED_CALL_ACTIVE)) {
+                    assertTrue("cause = " + data.mCause,
+                            DataFailCause.fromInt(data.mCause).
                             isPermanentFailure(mContext, mPhone.getSubId()));
                 } else {
-                    assertFalse("cause = " + data.mCause, DcFailCause.fromInt(data.mCause).
+                    assertFalse("cause = " + data.mCause,
+                            DataFailCause.fromInt(data.mCause).
                             isPermanentFailure(mContext, mPhone.getSubId()));
                 }
             }
@@ -198,37 +203,37 @@
     public void testEventLoggable() throws Exception {
         for (DcFailCauseData data : mFailCauseDataList) {
             assertEquals("cause = " + data.mCause, data.mEventLoggable,
-                    DcFailCause.fromInt(data.mCause).isEventLoggable());
+                    DataFailCause.fromInt(data.mCause).isEventLoggable());
         }
-        assertFalse(DcFailCause.fromInt(123456).isEventLoggable());
+        assertFalse(DataFailCause.fromInt(123456).isEventLoggable());
     }
 
     @Test
     @SmallTest
     public void testGetErrorCode() throws Exception {
         for (DcFailCauseData data : mFailCauseDataList) {
-            assertEquals(data.mCause, DcFailCause.fromInt(data.mCause).getErrorCode());
+            assertEquals(data.mCause, DataFailCause.fromInt(data.mCause).getErrorCode());
         }
-        assertEquals(DcFailCause.UNKNOWN.getErrorCode(),
-                DcFailCause.fromInt(123456).getErrorCode());
+        assertEquals(DataFailCause.UNKNOWN.getErrorCode(),
+                DataFailCause.fromInt(123456).getErrorCode());
     }
 
     @Test
     public void testIsRadioRestartFailureRegularDeactivation() {
-        assertFalse(DcFailCause.fromInt(DcFailCause.REGULAR_DEACTIVATION.getErrorCode())
+        assertFalse(DataFailCause.fromInt(DataFailCause.REGULAR_DEACTIVATION.getErrorCode())
                 .isRadioRestartFailure(mContext, mPhone.getSubId()));
         mPersistableBundle.putBoolean(CarrierConfigManager
                 .KEY_RESTART_RADIO_ON_PDP_FAIL_REGULAR_DEACTIVATION_BOOL, true);
-        assertTrue(DcFailCause.fromInt(DcFailCause.REGULAR_DEACTIVATION.getErrorCode())
+        assertTrue(DataFailCause.fromInt(DataFailCause.REGULAR_DEACTIVATION.getErrorCode())
                 .isRadioRestartFailure(mContext, mPhone.getSubId()));
     }
 
     @Test
     public void testIsRadioRestartFailureNotRegularDeactivation() {
-        DcFailCause randomCause = DcFailCause.fromInt(mFailCauseDataList
+        DataFailCause randomCause = DataFailCause.fromInt(mFailCauseDataList
                 .get(new Random().nextInt(mFailCauseDataList.size())).mCause);
-        while (randomCause == DcFailCause.REGULAR_DEACTIVATION) {
-            randomCause = DcFailCause.fromInt(mFailCauseDataList
+        while (randomCause == DataFailCause.REGULAR_DEACTIVATION) {
+            randomCause = DataFailCause.fromInt(mFailCauseDataList
                     .get(new Random().nextInt(mFailCauseDataList.size())).mCause);
         }
         assertFalse(randomCause.isRadioRestartFailure(mContext, mPhone.getSubId()));
diff --git a/tests/telephonytests/src/com/android/internal/telephony/rcs/RcsControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/rcs/RcsMessageStoreControllerTest.java
similarity index 73%
rename from tests/telephonytests/src/com/android/internal/telephony/rcs/RcsControllerTest.java
rename to tests/telephonytests/src/com/android/internal/telephony/rcs/RcsMessageStoreControllerTest.java
index d80b94b..869ec84 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/rcs/RcsControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/rcs/RcsMessageStoreControllerTest.java
@@ -18,19 +18,19 @@
 
 import static org.junit.Assert.assertEquals;
 
-import com.android.internal.telephony.RcsController;
+import com.android.internal.telephony.RcsMessageStoreController;
 import com.android.internal.telephony.TelephonyTest;
 
 import org.junit.Before;
 import org.junit.Test;
 
-public class RcsControllerTest extends TelephonyTest {
+public class RcsMessageStoreControllerTest extends TelephonyTest {
 
-    private RcsController mRcsController;
+    private RcsMessageStoreController mRcsMessageStoreController;
 
     @Before
     public void setUp() {
-        mRcsController = new RcsController(mContext, null);
+        mRcsMessageStoreController = new RcsMessageStoreController(mContext, null);
     }
 
     /**
@@ -38,6 +38,6 @@
      */
     @Test
     public void testGetMessageCount() {
-        assertEquals(1018, mRcsController.getMessageCount(0));
+        assertEquals(1018, mRcsMessageStoreController.getMessageCount(0));
     }
 }