ethernet: delete superfluous helper function
isCurrentCallback() is a trivial one liner that is more readable
inlined.
This change also renames handleIpEvent() to safelyPostOnHandler() to be
more descriptive.
Test: TH
Change-Id: I9224c9555f0b2ed22ff1cec5ae1c6e870c16820b
diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
index 6776920..ece10f3 100644
--- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -313,17 +313,12 @@
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 @@
@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