Merge "[Settings] Use TelephonyManasger.registerTelephonyCallback instead of TelephonyManager.listen" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-03-17 10:30:48 +00:00
committed by Android (Google) Code Review
12 changed files with 202 additions and 175 deletions

View File

@@ -124,13 +124,12 @@ public class MobileNetworkPreferenceControllerTest {
mLifecycleRegistry.handleLifecycleEvent(Event.ON_START);
verify(mController).onStart();
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE);
verify(mTelephonyManager).registerTelephonyCallback(
mContext.getMainExecutor(), mController.mTelephonyCallback);
mLifecycleRegistry.handleLifecycleEvent(Event.ON_STOP);
verify(mController).onStop();
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
PhoneStateListener.LISTEN_NONE);
verify(mTelephonyManager).unregisterTelephonyCallback(mController.mTelephonyCallback);
}
@Test
@@ -148,12 +147,12 @@ public class MobileNetworkPreferenceControllerTest {
mController.displayPreference(mScreen);
mLifecycleRegistry.handleLifecycleEvent(Event.ON_START);
verify(mController).onStart();
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE);
verify(mTelephonyManager).registerTelephonyCallback(
mContext.getMainExecutor(), mController.mTelephonyCallback);
doReturn(testCarrierName).when(mController).getSummary();
mController.mPhoneStateListener.onServiceStateChanged(null);
mController.mTelephonyCallback.onServiceStateChanged(null);
// Carrier name should be set.
Assert.assertEquals(mPreference.getSummary(), testCarrierName);