Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5c7c495 authored by Aaron Huang's avatar Aaron Huang
Browse files

Fix IpConfigStore dependencies on framework-connectivity

This change fixes IpConfigStore dependencies on framework-connectivity
hidden APIs.
- Use the version of SystemApi to new RouteInfo.
- Inline the implementation of isIPv4Default() directly because
  isDefaultRoute() is a public API so it can be used in this class.

(cherry-picked from ag/13945685)
Bug: 178777253
Test: FrameworksServicesTests:IpConfigStoreTest
Merged-In: I5ed1bc8bc8bee5b0c795fd8577a2d64628998e51
Change-Id: I5ed1bc8bc8bee5b0c795fd8577a2d64628998e51
parent 9503a309
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.net.IpConfiguration.IpAssignment;
import android.net.IpConfiguration.ProxySettings;
import android.net.LinkAddress;
import android.net.ProxyInfo;
import android.net.RouteInfo;
import android.net.StaticIpConfiguration;
import android.net.Uri;
import android.util.ArrayMap;
@@ -322,11 +321,14 @@ public class IpConfigStore {
                                if (in.readInt() == 1) {
                                    gateway = InetAddresses.parseNumericAddress(in.readUTF());
                                }
                                RouteInfo route = new RouteInfo(dest, gateway);
                                if (route.isIPv4Default() && gatewayAddress == null) {
                                // If the destination is a default IPv4 route, use the gateway
                                // address unless already set.
                                if (dest.getAddress() instanceof Inet4Address
                                        && dest.getPrefixLength() == 0 && gatewayAddress == null) {
                                    gatewayAddress = gateway;
                                } else {
                                    loge("Non-IPv4 default or duplicate route: " + route);
                                    loge("Non-IPv4 default or duplicate route: "
                                            + dest.getAddress());
                                }
                            }
                        } else if (key.equals(DNS_KEY)) {