From b95be5972e51ed4186c41af1c885a74134583561 Mon Sep 17 00:00:00 2001 From: Wally Yau Date: Wed, 22 May 2019 09:22:06 -0700 Subject: [PATCH] Fixed fatal exception in EthernetServiceThread When this.mIpConfig is not initialized, it will cause a java.lang.NullPointerException and put the device in a boot loop with the following error: FATAL EXCEPTION IN SYSTEM PROCESS: EthernetServiceThread Test: passed pre-submit boot test. Change-Id: I47df68071b4c07a4136c0abcbe69ee7ada7090e0 --- .../server/ethernet/EthernetNetworkFactory.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 6ed1310d2e..e3f114ed21 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -21,6 +21,7 @@ import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.NonNull; +import android.annotation.Nullable; import android.content.Context; import android.net.ConnectivityManager; import android.net.IpConfiguration; @@ -53,6 +54,7 @@ import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.lang.Math; import java.util.concurrent.ConcurrentHashMap; +import java.util.Objects; /** * {@link NetworkFactory} that represents Ethernet networks. @@ -252,10 +254,10 @@ public class EthernetNetworkFactory extends NetworkFactory { private boolean mLinkUp; private LinkProperties mLinkProperties = new LinkProperties(); - private volatile IIpClient mIpClient; - private IpClientCallbacksImpl mIpClientCallback; - private NetworkAgent mNetworkAgent; - private IpConfiguration mIpConfig; + private volatile @Nullable IIpClient mIpClient; + private @Nullable IpClientCallbacksImpl mIpClientCallback; + private @Nullable NetworkAgent mNetworkAgent; + private @Nullable IpConfiguration mIpConfig; /** * An object to contain all transport type information, including base network score and @@ -376,7 +378,7 @@ public class EthernetNetworkFactory extends NetworkFactory { } void setIpConfig(IpConfiguration ipConfig) { - if (this.mIpConfig.equals(ipConfig)) { + if (Objects.equals(this.mIpConfig, ipConfig)) { if (DBG) Log.d(TAG, "ipConfig have not changed,so ignore setIpConfig"); return; }