From d3c336a58f3d5d6f2a6405777beb4387a527e2c4 Mon Sep 17 00:00:00 2001 From: songferngwang Date: Wed, 8 May 2024 11:00:45 +0000 Subject: [PATCH] To correct the DDS when the user turn on mobile data If there is only one sim and the DDS is -1, when the user turns on the mobile data, the settings should correct the dds and set the mobile data on. Bug: 339382631 Test: Verify UI Change-Id: Ib0304dc1370a0d76310da2ce6ce0de12bfb275d8 --- .../network/NetworkCellularGroupProvider.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt index 7b7c85d23d6..28b7a9e1cab 100644 --- a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt +++ b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt @@ -410,11 +410,22 @@ suspend fun setMobileData( enabled: Boolean, ): Unit = withContext(Dispatchers.Default) { - Log.d(NetworkCellularGroupProvider.fileName, "setMobileData: $enabled") + Log.d(NetworkCellularGroupProvider.fileName, "setMobileData[$subId]: $enabled") + + var targetSubId = subId + val activeSubIdList = subscriptionManager?.activeSubscriptionIdList + if (activeSubIdList?.size == 1) { + targetSubId = activeSubIdList[0] + Log.d( + NetworkCellularGroupProvider.fileName, + "There is only one sim in the device, correct dds as $targetSubId" + ) + } + if (enabled) { - Log.d(NetworkCellularGroupProvider.fileName, "setDefaultData: [$subId]") - subscriptionManager?.setDefaultDataSubId(subId) + Log.d(NetworkCellularGroupProvider.fileName, "setDefaultData: [$targetSubId]") + subscriptionManager?.setDefaultDataSubId(targetSubId) } TelephonyRepository(context) - .setMobileData(subId, enabled, wifiPickerTrackerHelper) + .setMobileData(targetSubId, enabled, wifiPickerTrackerHelper) } \ No newline at end of file