Merge "ethernet: delete superfluous helper function" am: a6f0bf9c93

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2626729

Change-Id: I8164df1d6d523e57f8bb5e39e6e5cd3d992aba80
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-06-15 09:50:32 +00:00
committed by Automerger Merge Worker

View File

@@ -313,17 +313,12 @@ public class EthernetNetworkFactory {
mIpClientShutdownCv.block();
}
// At the time IpClient is stopped, an IpClient event may have already been posted on
// the back of the handler and is awaiting execution. Once that event is executed, the
// associated callback object may not be valid anymore
// (NetworkInterfaceState#mIpClientCallback points to a different object / null).
private boolean isCurrentCallback() {
return this == mIpClientCallback;
}
private void handleIpEvent(final @NonNull Runnable r) {
private void safelyPostOnHandler(Runnable r) {
mHandler.post(() -> {
if (!isCurrentCallback()) {
if (this != mIpClientCallback) {
// At the time IpClient is stopped, an IpClient event may have already been
// posted on the handler and is awaiting execution. Once that event is
// executed, the associated callback object may not be valid anymore.
Log.i(TAG, "Ignoring stale IpClientCallbacks " + this);
return;
}
@@ -333,24 +328,24 @@ public class EthernetNetworkFactory {
@Override
public void onProvisioningSuccess(LinkProperties newLp) {
handleIpEvent(() -> onIpLayerStarted(newLp));
safelyPostOnHandler(() -> onIpLayerStarted(newLp));
}
@Override
public void onProvisioningFailure(LinkProperties newLp) {
// This cannot happen due to provisioning timeout, because our timeout is 0. It can
// happen due to errors while provisioning or on provisioning loss.
handleIpEvent(() -> onIpLayerStopped());
safelyPostOnHandler(() -> onIpLayerStopped());
}
@Override
public void onLinkPropertiesChange(LinkProperties newLp) {
handleIpEvent(() -> updateLinkProperties(newLp));
safelyPostOnHandler(() -> updateLinkProperties(newLp));
}
@Override
public void onReachabilityLost(String logMsg) {
handleIpEvent(() -> updateNeighborLostEvent(logMsg));
safelyPostOnHandler(() -> updateNeighborLostEvent(logMsg));
}
@Override