Ignore potential SystemProperties errors when setting net.dns
Test: as follows
- built
- flashed
- booted
- "runtest frameworks-net" passes
Bug: 33308258
Bug: 36249702
Change-Id: I76ae853ceb61b7b900f36f9c3cd67b2d2284aab0
This commit is contained in:
@@ -4580,17 +4580,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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user