Merge "[Settings] Refactor PhoneStateListener"

This commit is contained in:
Bonian Chen
2019-11-15 09:08:57 +00:00
committed by Android (Google) Code Review
5 changed files with 59 additions and 42 deletions

View File

@@ -71,7 +71,7 @@ public class Enhanced4gBasePreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);

View File

@@ -72,22 +72,22 @@ public class WifiCallingPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
mPreference = new Preference(mContext);
mController = new WifiCallingPreferenceController(mContext, "wifi_calling") {
mController = spy(new WifiCallingPreferenceController(mContext, "wifi_calling") {
@Override
protected ImsMmTelManager getImsMmTelManager(int subId) {
return mImsMmTelManager;
}
};
});
mController.mCarrierConfigManager = mCarrierConfigManager;
mController.init(SUB_ID);
mController.mImsManager = mImsManager;
mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
mPreference.setKey(mController.getPreferenceKey());
when(mController.getTelephonyManager(mContext, SUB_ID)).thenReturn(mTelephonyManager);
mCarrierConfig = new PersistableBundle();
when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
@@ -112,8 +112,7 @@ public class WifiCallingPreferenceControllerTest {
@Test
public void updateState_notCallIdle_disable() {
when(mTelephonyManager.getCallState(SUB_ID)).thenReturn(
TelephonyManager.CALL_STATE_RINGING);
mController.mCallState = TelephonyManager.CALL_STATE_RINGING;
mController.updateState(mPreference);