Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0aed038b authored by Yu's avatar Yu
Browse files

Make p2p start searching after turning off airplane mode.



In the P2P page, p2p stops searching when airplane mode is turned on, and should start searching when airplane mode is turned off.

Bug: 255249207
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiP2pSettingsTest

Signed-off-by: default avatarYu <zhangyu34@xiaomi.com>
Change-Id: I71d5eb6c3d8533417e8ae9ac09e7fac73983644e
parent 20a3f8f9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -630,10 +630,13 @@ public class WifiP2pSettings extends DashboardFragment
    }

    private void handleP2pStateChanged() {
        updateSearchMenu(false);
        mThisDevicePreferenceController.setEnabled(mWifiP2pEnabled);
        mPersistentCategoryController.setEnabled(mWifiP2pEnabled);
        mPeerCategoryController.setEnabled(mWifiP2pEnabled);
        if (mWifiP2pEnabled) {
            startSearch();
        }
        updateSearchMenu(mWifiP2pEnabled);
    }

    private void updateSearchMenu(boolean searching) {
+14 −2
Original line number Diff line number Diff line
@@ -147,10 +147,10 @@ public class WifiP2pSettingsTest {
    }

    @Test
    public void beSearching_getP2pStateEnabledIntent_shouldBeFalse() {
    public void beSearching_getP2pStateDisabledIntent_shouldBeFalse() {
        final Bundle bundle = new Bundle();
        final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
        bundle.putInt(WifiP2pManager.EXTRA_WIFI_STATE, WifiP2pManager.WIFI_P2P_STATE_ENABLED);
        bundle.putInt(WifiP2pManager.EXTRA_WIFI_STATE, WifiP2pManager.WIFI_P2P_STATE_DISABLED);
        intent.putExtras(bundle);

        mFragment.mReceiver.onReceive(mContext, intent);
@@ -158,6 +158,18 @@ public class WifiP2pSettingsTest {
        assertThat(mFragment.mWifiP2pSearching).isFalse();
    }

    @Test
    public void beSearching_getP2pStateEnabledIntent_shouldBeTrue() {
        final Bundle bundle = new Bundle();
        final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
        bundle.putInt(WifiP2pManager.EXTRA_WIFI_STATE, WifiP2pManager.WIFI_P2P_STATE_ENABLED);
        intent.putExtras(bundle);

        mFragment.mReceiver.onReceive(mContext, intent);

        assertThat(mFragment.mWifiP2pSearching).isTrue();
    }

    @Test
    public void withEmptyP2pDeviceList_getP2pPeerChangeIntent_connectedDevicesShouldBeZero() {
        final WifiP2pDeviceList peers = new WifiP2pDeviceList();