Merge "Support new satellite datagram transfer state for NB IOT" into main
diff --git a/flags/ims.aconfig b/flags/ims.aconfig
index 84e491e..b41ef4d 100644
--- a/flags/ims.aconfig
+++ b/flags/ims.aconfig
@@ -1 +1,8 @@
-package: "com.android.internal.telephony.flags"
\ No newline at end of file
+package: "com.android.internal.telephony.flags"
+
+flag {
+    name: "conference_hold_unhold_changed_to_send_message"
+    namespace: "telephony"
+    description: "This flag controls Conference’s hold & unHold operation changed to send a message"
+    bug:"288002989"
+}
\ No newline at end of file
diff --git a/proto/src/persist_atoms.proto b/proto/src/persist_atoms.proto
index 5205616..722cb7c 100644
--- a/proto/src/persist_atoms.proto
+++ b/proto/src/persist_atoms.proto
@@ -381,6 +381,7 @@
     optional bool is_internet_pdn_up = 11;
     optional int32 fold_state = 12;
     optional bool override_voice_service = 13;
+    optional bool isDataEnabled = 14;
 
     // Internal use only
     optional int64 last_used_millis = 10001;
diff --git a/src/java/com/android/internal/telephony/NetworkTypeController.java b/src/java/com/android/internal/telephony/NetworkTypeController.java
index 73874e8..d1c8359 100644
--- a/src/java/com/android/internal/telephony/NetworkTypeController.java
+++ b/src/java/com/android/internal/telephony/NetworkTypeController.java
@@ -165,6 +165,7 @@
     private int mLtePlusThresholdBandwidth;
     private int mNrAdvancedThresholdBandwidth;
     private boolean mIncludeLteForNrAdvancedThresholdBandwidth;
+    private boolean mRatchetPccFieldsForSameAnchorNrCell;
     @NonNull private final Set<Integer> mAdditionalNrAdvancedBands = new HashSet<>();
     @NonNull private String mPrimaryTimerState;
     @NonNull private String mSecondaryTimerState;
@@ -300,6 +301,8 @@
                 CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT);
         mIncludeLteForNrAdvancedThresholdBandwidth = config.getBoolean(
                 CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL);
+        mRatchetPccFieldsForSameAnchorNrCell = config.getBoolean(
+                CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL);
         mEnableNrAdvancedWhileRoaming = config.getBoolean(
                 CarrierConfigManager.KEY_ENABLE_NR_ADVANCED_WHILE_ROAMING_BOOL);
         mAdditionalNrAdvancedBands.clear();
@@ -565,9 +568,9 @@
                     quit();
                     break;
                 case EVENT_INITIALIZE:
-                    // The reason that we do it here is because some of the works below requires
-                    // other modules (e.g. DataNetworkController, ServiceStateTracker), which is not
-                    // created yet when NetworkTypeController is created.
+                    // The reason that we do it here is that the work below requires other modules
+                    // (e.g. DataNetworkController, ServiceStateTracker), which are not created
+                    // when NetworkTypeController is created.
                     registerForAllEvents();
                     parseCarrierConfigs();
                     break;
@@ -1056,6 +1059,13 @@
     private void updatePhysicalChannelConfigs() {
         List<PhysicalChannelConfig> physicalChannelConfigs =
                 mPhone.getServiceStateTracker().getPhysicalChannelConfigList();
+        boolean isPccListEmpty = physicalChannelConfigs == null || physicalChannelConfigs.isEmpty();
+        if (isPccListEmpty && isUsingPhysicalChannelConfigForRrcDetection()) {
+            log("Physical channel configs updated: not updating PCC fields for empty PCC list "
+                    + "indicating RRC idle.");
+            mPhysicalChannelConfigs = physicalChannelConfigs;
+            return;
+        }
 
         int anchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
         int anchorLteCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
@@ -1088,33 +1098,24 @@
             anchorNrCellId = anchorLteCellId;
         }
 
-        boolean wasLastAnchorNrCellIdValid =
-                mLastAnchorNrCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
-        if ((physicalChannelConfigs == null || physicalChannelConfigs.isEmpty())
-                && wasLastAnchorNrCellIdValid && isUsingPhysicalChannelConfigForRrcDetection()) {
-            log("Keep same anchor NR cell and PCC fields for empty PCC list indicating RRC idle.");
-            // Set to mLastAnchorNrCellId since it will be UNKNOWN if the PCC list is empty
-            anchorNrCellId = mLastAnchorNrCellId;
-        }
-        if (mLastAnchorNrCellId == anchorNrCellId && wasLastAnchorNrCellIdValid) {
+        if (anchorNrCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
+            if (!isPccListEmpty) {
+                log("Ignoring physical channel config fields without an anchor NR cell, "
+                        + "either due to LTE-only configs or an unspecified cell ID.");
+            }
+            mRatchetedNrBandwidths = 0;
+            mRatchetedNrBands.clear();
+        } else if (anchorNrCellId == mLastAnchorNrCellId && mRatchetPccFieldsForSameAnchorNrCell) {
             log("Ratchet physical channel config fields since anchor NR cell is the same.");
             mRatchetedNrBandwidths = Math.max(mRatchetedNrBandwidths, nrBandwidths);
             mRatchetedNrBands.addAll(nrBands);
         } else {
-            if (anchorNrCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
-                if (wasLastAnchorNrCellIdValid) {
-                    // Only log when the previous anchor NR cell was valid to prevent log spam
-                    log("Clearing physical channel config fields without an anchor NR cell, "
-                            + "either due to LTE-only configs or an unspecified cell ID.");
-                }
-                mRatchetedNrBandwidths = 0;
-                mRatchetedNrBands.clear();
-            } else {
-                log("Not ratcheting physical channel config fields since anchor NR cell changed "
+            if (mRatchetPccFieldsForSameAnchorNrCell) {
+                log("Not ratcheting physical channel config fields since anchor NR cell changed: "
                         + mLastAnchorNrCellId + " -> " + anchorNrCellId);
-                mRatchetedNrBandwidths = nrBandwidths;
-                mRatchetedNrBands = nrBands;
             }
+            mRatchetedNrBandwidths = nrBandwidths;
+            mRatchetedNrBands = nrBands;
         }
 
         mLastAnchorNrCellId = anchorNrCellId;
@@ -1351,7 +1352,7 @@
         // Check PCO requirement. For carriers using PCO to indicate whether the data connection is
         // NR advanced capable, mNrAdvancedCapablePcoId should be configured to non-zero.
         if (mNrAdvancedCapablePcoId > 0 && !mIsNrAdvancedAllowedByPco) {
-            if (DBG) log("isNrAdvanced: false because PCO ID " + mNrAdvancedCapablePcoId + " <= 0");
+            if (DBG) log("isNrAdvanced: not allowed by PCO for PCO ID " + mNrAdvancedCapablePcoId);
             return false;
         }
 
@@ -1460,6 +1461,9 @@
                 + mIsTimerResetEnabledForLegacyStateRrcIdle);
         pw.println("mLtePlusThresholdBandwidth=" + mLtePlusThresholdBandwidth);
         pw.println("mNrAdvancedThresholdBandwidth=" + mNrAdvancedThresholdBandwidth);
+        pw.println("mIncludeLteForNrAdvancedThresholdBandwidth="
+                + mIncludeLteForNrAdvancedThresholdBandwidth);
+        pw.println("mRatchetPccFieldsForSameAnchorNrCell=" + mRatchetPccFieldsForSameAnchorNrCell);
         pw.println("mRatchetedNrBandwidths=" + mRatchetedNrBandwidths);
         pw.println("mAdditionalNrAdvancedBandsList=" + mAdditionalNrAdvancedBands);
         pw.println("mRatchetedNrBands=" + mRatchetedNrBands);
diff --git a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
index a04a63a..1a53ee6 100644
--- a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
+++ b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
@@ -933,7 +933,8 @@
                 state.isEmergencyOnly,
                 state.isInternetPdnUp,
                 state.foldState,
-                state.overrideVoiceService);
+                state.overrideVoiceService,
+                state.isDataEnabled);
     }
 
     private static StatsEvent buildStatsEvent(VoiceCallRatUsage usage) {
diff --git a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
index c3312e1..d495ca2 100644
--- a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
+++ b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
@@ -1710,7 +1710,8 @@
                     && state.isEmergencyOnly == key.isEmergencyOnly
                     && state.isInternetPdnUp == key.isInternetPdnUp
                     && state.foldState == key.foldState
-                    && state.overrideVoiceService == key.overrideVoiceService) {
+                    && state.overrideVoiceService == key.overrideVoiceService
+                    && state.isDataEnabled == key.isDataEnabled) {
                 return state;
             }
         }
diff --git a/src/java/com/android/internal/telephony/metrics/ServiceStateStats.java b/src/java/com/android/internal/telephony/metrics/ServiceStateStats.java
index 982a8f5..14ce2cc 100644
--- a/src/java/com/android/internal/telephony/metrics/ServiceStateStats.java
+++ b/src/java/com/android/internal/telephony/metrics/ServiceStateStats.java
@@ -131,6 +131,7 @@
             newState.isInternetPdnUp = isInternetPdnUp(mPhone);
             newState.foldState = mDeviceStateHelper.getFoldState();
             newState.overrideVoiceService = mOverrideVoiceService.get();
+            newState.isDataEnabled = mPhone.getDataSettingsManager().isDataEnabled();
             TimestampedServiceState prevState =
                     mLastState.getAndSet(new TimestampedServiceState(newState, now));
             addServiceStateAndSwitch(
@@ -300,6 +301,7 @@
         copy.isInternetPdnUp = state.isInternetPdnUp;
         copy.foldState = state.foldState;
         copy.overrideVoiceService = state.overrideVoiceService;
+        copy.isDataEnabled = state.isDataEnabled;
         return copy;
     }
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
index fbf169c..7f15af8 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
@@ -571,6 +571,8 @@
         mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                 new int[]{41, 77});
         mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
+        mBundle.putBoolean(CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL,
+                true);
         sendCarrierConfigChanged();
 
         // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
@@ -632,6 +634,101 @@
     }
 
     @Test
+    public void testEventPhysicalChannelConfigChangedWithoutRatcheting() throws Exception {
+        testTransitionToCurrentStateNrConnected();
+        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
+                new int[]{41, 77});
+        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
+        sendCarrierConfigChanged();
+
+        // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
+        PhysicalChannelConfig pcc1 = new PhysicalChannelConfig.Builder()
+                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
+                .setPhysicalCellId(1)
+                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
+                .setCellBandwidthDownlinkKhz(19999)
+                .build();
+        // Secondary serving NR PCC with cell ID = 2, band = 41, bandwidth = 10000
+        PhysicalChannelConfig pcc2 = new PhysicalChannelConfig.Builder()
+                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
+                .setPhysicalCellId(2)
+                .setCellConnectionStatus(CellInfo.CONNECTION_SECONDARY_SERVING)
+                .setCellBandwidthDownlinkKhz(10000)
+                .setBand(41)
+                .build();
+
+        List<PhysicalChannelConfig> physicalChannelConfigs = new ArrayList<>();
+        physicalChannelConfigs.add(pcc1);
+        physicalChannelConfigs.add(pcc2);
+        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
+
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected_mmwave", getCurrentState().getName());
+
+        // bands and bandwidths should stay ratcheted even if an empty PCC list is sent
+        doReturn(new ArrayList<>()).when(mSST).getPhysicalChannelConfigList();
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected_mmwave", getCurrentState().getName());
+
+        // bands and bandwidths should change if PCC list changes
+        physicalChannelConfigs.remove(pcc2);
+        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected", getCurrentState().getName());
+    }
+
+    @Test
+    public void testEventPhysicalChannelConfigChangedUsingUserDataForRrc() throws Exception {
+        testTransitionToCurrentStateNrConnected();
+        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
+                new int[]{41, 77});
+        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
+        mBundle.putBoolean(CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL,
+                true);
+        sendCarrierConfigChanged();
+
+        // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
+        PhysicalChannelConfig pcc1 = new PhysicalChannelConfig.Builder()
+                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
+                .setPhysicalCellId(1)
+                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
+                .setCellBandwidthDownlinkKhz(19999)
+                .build();
+        // Secondary serving NR PCC with cell ID = 2, band = 41, bandwidth = 10000
+        PhysicalChannelConfig pcc2 = new PhysicalChannelConfig.Builder()
+                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
+                .setPhysicalCellId(2)
+                .setCellConnectionStatus(CellInfo.CONNECTION_SECONDARY_SERVING)
+                .setCellBandwidthDownlinkKhz(10000)
+                .setBand(41)
+                .build();
+
+        List<PhysicalChannelConfig> physicalChannelConfigs = new ArrayList<>();
+        physicalChannelConfigs.add(pcc1);
+        physicalChannelConfigs.add(pcc2);
+        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
+
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected_mmwave", getCurrentState().getName());
+
+        // bands and bandwidths should not stay the same even if an empty PCC list is sent
+        doReturn(new ArrayList<>()).when(mSST).getPhysicalChannelConfigList();
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected", getCurrentState().getName());
+
+        // bands and bandwidths should change if PCC list changes
+        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
+        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
+        processAllMessages();
+        assertEquals("connected_mmwave", getCurrentState().getName());
+    }
+
+    @Test
     public void testNrPhysicalChannelChangeFromNrConnectedMmwaveToLteConnected() throws Exception {
         testTransitionToCurrentStateNrConnectedMmwave();
         doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java b/tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java
index 5d7eb9c..2509b8c 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java
@@ -158,6 +158,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -330,6 +331,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -342,6 +344,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -379,6 +382,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, state.dataRat);
@@ -391,6 +395,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -425,6 +430,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -466,6 +472,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -504,6 +511,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -516,6 +524,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         CellularDataServiceSwitch serviceSwitch = serviceSwitchCaptor.getAllValues().get(0);
         assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, serviceSwitch.ratFrom);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, serviceSwitch.ratTo);
@@ -557,6 +566,7 @@
         assertEquals(CARRIER1_ID, state.carrierId);
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -568,6 +578,7 @@
         assertEquals(CARRIER1_ID, state.carrierId);
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -597,6 +608,7 @@
         assertEquals(0L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -638,6 +650,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -650,6 +663,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(2);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -662,6 +676,7 @@
         assertEquals(400L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(3);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -674,6 +689,7 @@
         assertEquals(800L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -719,6 +735,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, state.dataRat);
@@ -731,6 +748,7 @@
         assertEquals(5000L, state.totalTimeMillis);
         assertEquals(true, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(2);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -743,6 +761,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -808,6 +827,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.dataRat);
@@ -820,6 +840,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(2);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.dataRat);
@@ -832,6 +853,7 @@
         assertEquals(400L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         CellularDataServiceSwitch serviceSwitch = serviceSwitchCaptor.getAllValues().get(0);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, serviceSwitch.ratFrom);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, serviceSwitch.ratTo);
@@ -888,6 +910,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.dataRat);
@@ -901,6 +924,7 @@
         assertEquals(400L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         CellularDataServiceSwitch serviceSwitch = serviceSwitchCaptor.getAllValues().get(0);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, serviceSwitch.ratFrom);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, serviceSwitch.ratTo);
@@ -957,6 +981,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -969,6 +994,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(2);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.dataRat);
@@ -981,6 +1007,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = serviceStateCaptor.getAllValues().get(3);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, state.dataRat);
@@ -993,6 +1020,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         CellularDataServiceSwitch serviceSwitch = serviceSwitchCaptor.getAllValues().get(0);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, serviceSwitch.ratFrom);
         assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, serviceSwitch.ratTo);
@@ -1054,6 +1082,7 @@
         assertEquals(100L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         state = captor.getAllValues().get(1);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.voiceRat);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, state.dataRat);
@@ -1066,6 +1095,7 @@
         assertEquals(200L, state.totalTimeMillis);
         assertEquals(false, state.isEmergencyOnly);
         assertEquals(true, state.isInternetPdnUp);
+        assertEquals(true, state.isDataEnabled);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -1320,6 +1350,7 @@
         doReturn(1).when(mSecondPhone).getPhoneId();
         doReturn(1).when(mUiccController).getSlotIdFromPhoneId(1);
         doReturn(carrierId).when(mSecondPhone).getCarrierId();
+        doReturn(mDataSettingsManager).when(mSecondPhone).getDataSettingsManager();
 
         doReturn(true).when(mPhysicalSlot1).isActive();
         doReturn(CardState.CARDSTATE_PRESENT).when(mPhysicalSlot1).getCardState();