Fix crash when call getMobileTemplate am: 9132535e5e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24002328
Change-Id: I01c40793839a7d5fbd0b7834c67184c228356c0f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/network/telephony/DataUsagePreferenceController.kt b/src/com/android/settings/network/telephony/DataUsagePreferenceController.kt
index 14adf6f..88da325 100644
--- a/src/com/android/settings/network/telephony/DataUsagePreferenceController.kt
+++ b/src/com/android/settings/network/telephony/DataUsagePreferenceController.kt
@@ -30,6 +30,7 @@
import androidx.preference.PreferenceScreen
import com.android.settings.R
import com.android.settings.datausage.DataUsageUtils
+import com.android.settings.datausage.lib.DataUsageLib
import com.android.settingslib.net.DataUsageController
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -96,7 +97,7 @@
private fun getNetworkTemplate(): NetworkTemplate? = when {
SubscriptionManager.isValidSubscriptionId(mSubId) -> {
- DataUsageUtils.getMobileTemplate(mContext, mSubId)
+ DataUsageLib.getMobileTemplate(mContext, mSubId)
}
else -> null
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt
index a9d343f..a42e41e 100644
--- a/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt
@@ -32,6 +32,7 @@
import com.android.settings.core.BasePreferenceController.AVAILABLE
import com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE
import com.android.settings.datausage.DataUsageUtils
+import com.android.settings.datausage.lib.DataUsageLib
import com.android.settingslib.net.DataUsageController
import com.android.settingslib.net.DataUsageController.DataUsageInfo
import com.android.settingslib.spa.testutils.waitUntil
@@ -80,13 +81,14 @@
.initMocks(this)
.mockStatic(SubscriptionManager::class.java)
.spyStatic(DataUsageUtils::class.java)
+ .spyStatic(DataUsageLib::class.java)
.strictness(Strictness.LENIENT)
.startMocking()
whenever(SubscriptionManager.isValidSubscriptionId(SUB_ID)).thenReturn(true)
ExtendedMockito.doReturn(true).`when` { DataUsageUtils.hasMobileData(context) }
ExtendedMockito.doReturn(networkTemplate)
- .`when` { DataUsageUtils.getMobileTemplate(context, SUB_ID) }
+ .`when` { DataUsageLib.getMobileTemplate(context, SUB_ID) }
preference.key = TEST_KEY
whenever(preferenceScreen.findPreference<Preference>(TEST_KEY)).thenReturn(preference)