Make P2P Settings channel static
P2P Settings creates a P2P channel but does not close the channel if there is a P2P connection. This causes multiple channels to accumulate if P2P Settings is repeatedly opened and closed. Making the channel static will ensure that each time a new P2P Settings activity is created, the existing open channel will be used. Bug: 259364357 Test: build Change-Id: I999b108bc3e3c22519398a55b503078c1069cef1
This commit is contained in:
@@ -338,7 +338,7 @@ public class WifiP2pSettingsTest {
|
||||
public void onStop_notLastGroupFormed_shouldCloseChannel() {
|
||||
mFragment.onStop();
|
||||
|
||||
assertThat(mFragment.mChannel).isNull();
|
||||
assertThat(mFragment.sChannel).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -355,7 +355,7 @@ public class WifiP2pSettingsTest {
|
||||
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
|
||||
|
||||
mFragment.onStart();
|
||||
assertThat(mFragment.mChannel).isNotNull();
|
||||
assertThat(mFragment.sChannel).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -526,7 +526,7 @@ public class WifiP2pSettingsTest {
|
||||
|
||||
@Test
|
||||
public void onCreateView_withNullP2pManager_shouldGetP2pManagerAgain() {
|
||||
mFragment.mChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.sChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.mWifiP2pManager = null;
|
||||
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, new Bundle());
|
||||
@@ -537,7 +537,7 @@ public class WifiP2pSettingsTest {
|
||||
@Test
|
||||
public void onCreateView_withNullChannel_shouldSetP2pManagerNull() {
|
||||
doReturn(null).when(mWifiP2pManager).initialize(any(), any(), any());
|
||||
mFragment.mChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.sChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, new Bundle());
|
||||
|
||||
assertThat(mFragment.mWifiP2pManager).isNull();
|
||||
|
||||
Reference in New Issue
Block a user