diff options
author | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-03-10 08:03:53 +0000 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2020-03-11 03:48:04 +0000 |
commit | aa561db2185e79ef3cf91932864b7007f902dadd (patch) | |
tree | 739d8470c09c70b216c534c78eabe2f54fa71248 | |
parent | faac06e3e1412364512e46f38e63c6d2ca7548c1 (diff) |
Make IpClient populate the DHCP server address in LinkProperties
Bug: 134098566
Test:
lunch arm_aosp-userdebug
make -j32
Change-Id: Ide9610f9b17992eef83e1c42ac71b1b79c179f44
Merged-In: If86a6303671b03bb2ccf98de7e9d77020b013d2f
(cherry picked from commit 10d243214ae933d063affdd2b4f6c1f837279586)
4 files changed, 31 insertions, 0 deletions
diff --git a/apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java b/apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java index b24b473..0c03883 100644 --- a/apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java +++ b/apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java @@ -27,6 +27,8 @@ import androidx.annotation.VisibleForTesting; import com.android.networkstack.apishim.CaptivePortalDataShim; import com.android.networkstack.apishim.NetworkInformationShim; +import java.net.Inet4Address; + /** * Compatibility implementation of {@link NetworkInformationShim}. * @@ -84,4 +86,10 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) { return new LinkProperties(lp); } + + @Override + public void setDhcpServerAddress(@NonNull LinkProperties lp, + @NonNull Inet4Address serverAddress) { + // Not supported on this API level: no-op + } } diff --git a/apishim/30/com/android/networkstack/apishim/NetworkInformationShimImpl.java b/apishim/30/com/android/networkstack/apishim/NetworkInformationShimImpl.java index 6466662..e04cda5 100644 --- a/apishim/30/com/android/networkstack/apishim/NetworkInformationShimImpl.java +++ b/apishim/30/com/android/networkstack/apishim/NetworkInformationShimImpl.java @@ -25,6 +25,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import java.net.Inet4Address; + /** * Compatibility implementation of {@link NetworkInformationShim}. */ @@ -81,4 +83,10 @@ public class NetworkInformationShimImpl extends public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) { return lp.makeSensitiveFieldsParcelingCopy(); } + + @Override + public void setDhcpServerAddress(@NonNull LinkProperties lp, + @NonNull Inet4Address serverAddress) { + lp.setDhcpServerAddress(serverAddress); + } } diff --git a/apishim/common/com/android/networkstack/apishim/NetworkInformationShim.java b/apishim/common/com/android/networkstack/apishim/NetworkInformationShim.java index c266043..246a8ef 100644 --- a/apishim/common/com/android/networkstack/apishim/NetworkInformationShim.java +++ b/apishim/common/com/android/networkstack/apishim/NetworkInformationShim.java @@ -23,6 +23,8 @@ import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import java.net.Inet4Address; + /** * Compatibility interface for network info classes such as {@link LinkProperties} and * {@link NetworkCapabilities}. @@ -56,4 +58,12 @@ public interface NetworkInformationShim { */ @NonNull LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull LinkProperties lp); + + /** + * @see LinkProperties#setDhcpServerAddress() + */ + @NonNull + void setDhcpServerAddress(@NonNull LinkProperties lp, + @NonNull Inet4Address serverAddress); + } diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 173f136..163005a 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java @@ -1195,6 +1195,10 @@ public class IpClient extends StateMachine { newLp.setMtu(mDhcpResults.mtu); } + if (mDhcpResults.serverAddress != null) { + mShim.setDhcpServerAddress(newLp, mDhcpResults.serverAddress); + } + final String capportUrl = mDhcpResults.captivePortalApiUrl; // Uri.parse does no syntax check; do a simple regex check to eliminate garbage. // If the URL is still incorrect data fetching will fail later, which is fine. @@ -1272,6 +1276,7 @@ public class IpClient extends StateMachine { if (DBG) { Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")"); + Log.d(mTag, "handleIPv4Success newLp{" + newLp + "}"); } mCallback.onNewDhcpResults(dhcpResults); maybeSaveNetworkToIpMemoryStore(); |