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

Commit 4b7af547 authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Merge "Ignore potential SystemProperties errors when setting net.dns" am:...

Merge "Ignore potential SystemProperties errors when setting net.dns" am: f854c903 am: 1303b8b9 am: 1d3528ba
am: 23c01703

Change-Id: I1f99a5fdcf2285a2579610d1eb0a946d21043e3d
parents 7586a5e4 23c01703
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -4452,17 +4452,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
        int last = 0;
        int last = 0;
        for (InetAddress dns : dnses) {
        for (InetAddress dns : dnses) {
            ++last;
            ++last;
            String key = "net.dns" + last;
            setNetDnsProperty(last, dns.getHostAddress());
            String value = dns.getHostAddress();
            mSystemProperties.set(key, value);
        }
        }
        for (int i = last + 1; i <= mNumDnsEntries; ++i) {
        for (int i = last + 1; i <= mNumDnsEntries; ++i) {
            String key = "net.dns" + i;
            setNetDnsProperty(i, "");
            mSystemProperties.set(key, "");
        }
        }
        mNumDnsEntries = last;
        mNumDnsEntries = last;
    }
    }


    private void setNetDnsProperty(int which, String value) {
        final String key = "net.dns" + which;
        // Log and forget errors setting unsupported properties.
        try {
            mSystemProperties.set(key, value);
        } catch (Exception e) {
            Log.e(TAG, "Error setting unsupported net.dns property: ", e);
        }
    }

    private String getNetworkPermission(NetworkCapabilities nc) {
    private String getNetworkPermission(NetworkCapabilities nc) {
        // TODO: make these permission strings AIDL constants instead.
        // TODO: make these permission strings AIDL constants instead.
        if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) {
        if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) {