Fixed unit tests
Fixed unit tests when subscription manager service
is enabled.
Bug: 239607619
Test: Manual test with single SIM + atest FrameworksTelephonyTests
Change-Id: Ic167defc7337e13d83c3dadda2c84b27aa20fba3
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 58b8299..5ba148d 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -777,6 +777,7 @@
}
private void updateSubscriptionDatabase(int phoneId) {
+ logd("updateSubscriptionDatabase: phoneId=" + phoneId);
String configPackageName;
PersistableBundle configToSend;
int carrierId = getSpecificCarrierIdForPhoneId(phoneId);
diff --git a/tests/src/com/android/phone/CarrierConfigLoaderTest.java b/tests/src/com/android/phone/CarrierConfigLoaderTest.java
index 6807422..45a53f7 100644
--- a/tests/src/com/android/phone/CarrierConfigLoaderTest.java
+++ b/tests/src/com/android/phone/CarrierConfigLoaderTest.java
@@ -54,7 +54,9 @@
import com.android.TelephonyTestBase;
import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SubscriptionInfoUpdater;
+import com.android.internal.telephony.subscription.SubscriptionManagerService;
import org.junit.After;
import org.junit.Before;
@@ -87,6 +89,7 @@
@Mock PackageManager mPackageManager;
@Mock PackageInfo mPackageInfo;
@Mock SubscriptionInfoUpdater mSubscriptionInfoUpdater;
+ @Mock SubscriptionManagerService mSubscriptionManagerService;
@Mock SharedPreferences mSharedPreferences;
@Mock TelephonyRegistryManager mTelephonyRegistryManager;
@@ -100,6 +103,9 @@
public void setUp() throws Exception {
super.setUp();
+ replaceInstance(SubscriptionManagerService.class, "sInstance", null,
+ mSubscriptionManagerService);
+
// TODO: replace doReturn/when with when/thenReturn which is more readable
doReturn(mSharedPreferences).when(mContext).getSharedPreferences(anyString(), anyInt());
doReturn(Build.FINGERPRINT).when(mSharedPreferences).getString(eq("build_fingerprint"),
@@ -271,9 +277,15 @@
mTestableLooper.processAllMessages();
assertThat(mCarrierConfigLoader.getOverrideConfig(DEFAULT_PHONE_ID).isEmpty()).isTrue();
- verify(mSubscriptionInfoUpdater).updateSubscriptionByCarrierConfigAndNotifyComplete(
- eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
- any(PersistableBundle.class), any(Message.class));
+ if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
+ verify(mSubscriptionManagerService).updateSubscriptionByCarrierConfig(
+ eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
+ any(PersistableBundle.class), any(Runnable.class));
+ } else {
+ verify(mSubscriptionInfoUpdater).updateSubscriptionByCarrierConfigAndNotifyComplete(
+ eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
+ any(PersistableBundle.class), any(Message.class));
+ }
}
/**
@@ -294,9 +306,15 @@
assertThat(mCarrierConfigLoader.getOverrideConfig(DEFAULT_PHONE_ID).getInt(
CARRIER_CONFIG_EXAMPLE_KEY)).isEqualTo(CARRIER_CONFIG_EXAMPLE_VALUE);
- verify(mSubscriptionInfoUpdater).updateSubscriptionByCarrierConfigAndNotifyComplete(
- eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
- any(PersistableBundle.class), any(Message.class));
+ if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
+ verify(mSubscriptionManagerService).updateSubscriptionByCarrierConfig(
+ eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
+ any(PersistableBundle.class), any(Runnable.class));
+ } else {
+ verify(mSubscriptionInfoUpdater).updateSubscriptionByCarrierConfigAndNotifyComplete(
+ eq(DEFAULT_PHONE_ID), eq(PLATFORM_CARRIER_CONFIG_PACKAGE),
+ any(PersistableBundle.class), any(Message.class));
+ }
}
/**