Allow WifiSettings to show old APs on app resume.

MANUAL MERGE of ag/2398149 to avoid merge conflicts when trying to
submit to oc-dev.

If we do not have any recent scan results, show the previous APs from
when the app was last paused, by not triggering a force update.

Accompanying changes are also made in WifiTracker to prevent
onAccessPointsChanged callbacks from being invoked until the tracker
receives a new 'SCAN_RESULTS_AVAILABLE' broadcast (ag/2409026).

Bug: b/38212080
Test: runtest --path
packages/apps/Settings/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
one minute later.

Change-Id: I4f9b2ec855e057e28235b0253ab42c6b4521bebc
This commit is contained in:
Sundeep Ghuman
2017-06-12 18:16:53 -07:00
parent 6f365765f7
commit 4ae59dde43
2 changed files with 48 additions and 5 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.android.settings.wifi;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
@@ -45,6 +46,7 @@ import org.mockito.MockitoAnnotations;
import java.util.List;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
@@ -52,10 +54,14 @@ import static android.support.test.espresso.matcher.ViewMatchers.Visibility.VISI
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static com.google.common.truth.Truth.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -217,4 +223,23 @@ public class WifiSettingsUiTest {
onView(withText(CONNECTED)).check(matches(isDisplayed()));
}
@Test
public void resumingAp_shouldNotForceUpdateWhenExistingAPsAreListed() {
setWifiState(WifiManager.WIFI_STATE_ENABLED);
setupConnectedAccessPoint();
when(mWifiTracker.isConnected()).thenReturn(true);
launchActivity();
onView(withText(CONNECTED)).check(matches(isDisplayed()));
verify(mWifiTracker).forceUpdate();
Activity activity = mActivityRule.getActivity();
activity.finish();
getInstrumentation().waitForIdleSync();
getInstrumentation().callActivityOnStart(activity);
verify(mWifiTracker, atMost(1)).forceUpdate();
}
}