Merge "Tethering: ignore duplicate upstream changed event" am: c2e434bbc7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2390555 Change-Id: If9f0aa16423dc89af6004250b19b6749bea18aef Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
cedb8d1153
2 changed files with 12 additions and 9 deletions
|
|
@ -157,6 +157,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
|
|
@ -1845,11 +1846,12 @@ public class Tethering {
|
|||
|
||||
setUpstreamNetwork(ns);
|
||||
final Network newUpstream = (ns != null) ? ns.network : null;
|
||||
if (mTetherUpstream != newUpstream) {
|
||||
if (!Objects.equals(mTetherUpstream, newUpstream)) {
|
||||
mTetherUpstream = newUpstream;
|
||||
reportUpstreamChanged(mTetherUpstream);
|
||||
// Need to notify capabilities change after upstream network changed because new
|
||||
// network's capabilities should be checked every time.
|
||||
// Need to notify capabilities change after upstream network changed because
|
||||
// upstream may switch to existing network which don't have
|
||||
// UpstreamNetworkMonitor.EVENT_ON_CAPABILITIES callback.
|
||||
mNotificationUpdater.onUpstreamCapabilitiesChanged(
|
||||
(ns != null) ? ns.networkCapabilities : null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2685,10 +2685,9 @@ public class TetheringTest {
|
|||
final UpstreamNetworkState upstreamState2 = buildMobileIPv4UpstreamState();
|
||||
initTetheringUpstream(upstreamState2);
|
||||
stateMachine.chooseUpstreamType(true);
|
||||
// Bug: duplicated upstream change event.
|
||||
mTetheringEventCallback.expectUpstreamChanged(upstreamState2.network);
|
||||
inOrder.verify(mNotificationUpdater)
|
||||
.onUpstreamCapabilitiesChanged(upstreamState2.networkCapabilities);
|
||||
// Expect that no upstream change event and capabilities changed event.
|
||||
mTetheringEventCallback.assertNoUpstreamChangeCallback();
|
||||
inOrder.verify(mNotificationUpdater, never()).onUpstreamCapabilitiesChanged(any());
|
||||
|
||||
// Set the upstream with the same network ID but different object and different capability.
|
||||
final UpstreamNetworkState upstreamState3 = buildMobileIPv4UpstreamState();
|
||||
|
|
@ -2696,11 +2695,13 @@ public class TetheringTest {
|
|||
upstreamState3.networkCapabilities.addCapability(NET_CAPABILITY_VALIDATED);
|
||||
initTetheringUpstream(upstreamState3);
|
||||
stateMachine.chooseUpstreamType(true);
|
||||
// Bug: duplicated upstream change event.
|
||||
mTetheringEventCallback.expectUpstreamChanged(upstreamState3.network);
|
||||
// Expect that no upstream change event and capabilities changed event.
|
||||
mTetheringEventCallback.assertNoUpstreamChangeCallback();
|
||||
stateMachine.handleUpstreamNetworkMonitorCallback(EVENT_ON_CAPABILITIES, upstreamState3);
|
||||
inOrder.verify(mNotificationUpdater)
|
||||
.onUpstreamCapabilitiesChanged(upstreamState3.networkCapabilities);
|
||||
|
||||
|
||||
// Lose upstream.
|
||||
initTetheringUpstream(null);
|
||||
stateMachine.chooseUpstreamType(true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue