Fix tethering summary when airplane mode is off

When airplane mode is off, fall back to default summary
(tether off summary). It should be fine because once tether
state get updated again, it will go through original listener
to update the summary.

Change-Id: Iba9b56f452e72365ea964d841ee156a2625c0ae1
Fixes: 79721162
Test: RunSettingsRoboTests
This commit is contained in:
Lei Yu
2018-05-17 12:32:02 -07:00
parent cd28a977ca
commit 4fec12cbbf
2 changed files with 24 additions and 2 deletions

View File

@@ -123,7 +123,7 @@ public class WifiTetherPreferenceControllerTest {
}
@Test
public void testReceiver_goingToAirplaneMode_shouldClearPreferenceSummary() {
public void testReceiver_turnOnAirplaneMode_clearPreferenceSummary() {
final ContentResolver cr = mock(ContentResolver.class);
when(mContext.getContentResolver()).thenReturn(cr);
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, 1);
@@ -137,6 +137,21 @@ public class WifiTetherPreferenceControllerTest {
"Unavailable because airplane mode is turned on");
}
@Test
public void testReceiver_turnOffAirplaneMode_displayOffSummary() {
final ContentResolver cr = mock(ContentResolver.class);
when(mContext.getContentResolver()).thenReturn(cr);
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, 0);
mController.displayPreference(mScreen);
final BroadcastReceiver receiver = ReflectionHelpers.getField(mController, "mReceiver");
final Intent broadcast = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
receiver.onReceive(RuntimeEnvironment.application, broadcast);
assertThat(mPreference.getSummary().toString()).isEqualTo(
"Not sharing internet or content with other devices");
}
@Test
public void testHandleWifiApStateChanged_stateEnabling_showEnablingSummary() {
mController.handleWifiApStateChanged(WifiManager.WIFI_AP_STATE_ENABLING, 0 /* reason */);