[Settings] Refactor PhoneStateListener

Remove Looper and update of mSubId

Bug: 144542981
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=VideoCallingPreferenceControllerTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest

Change-Id: Ie6ae5b5914322644f2655e585b03a6b685bbc84a
This commit is contained in:
Bonian Chen
2019-11-15 14:43:29 +08:00
parent 7d0e3a4929
commit 21361e1f84
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);