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
This commit is contained in:
songferngwang
2024-05-08 11:00:45 +00:00
committed by SongFerng Wang
parent 965da3df32
commit d3c336a58f

View File

@@ -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)
}