summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/NetworkManagementService.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server/NetworkManagementService.java')
-rw-r--r--services/java/com/android/server/NetworkManagementService.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 0b4b958..b34906f 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -949,4 +949,65 @@ class NetworkManagementService extends INetworkManagementService.Stub {
public int getInterfaceTxThrottle(String iface) {
return getInterfaceThrottle(iface, false);
}
+
+ public void setDefaultInterfaceForDns(String iface) throws IllegalStateException {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
+ try {
+ String cmd = "resolver setdefaultif " + iface;
+
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ throw new IllegalStateException(
+ "Error communicating with native daemon to set default interface", e);
+ }
+ }
+
+ public void setDnsServersForInterface(String iface, String[] servers)
+ throws IllegalStateException {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CHANGE_NETWORK_STATE,
+ "NetworkManagementService");
+ try {
+ String cmd = "resolver setifdns " + iface;
+ for (String s : servers) {
+ if (s != null && !"0.0.0.0".equals(s) &&
+ !"::".equals(s) && !"0:0:0:0:0:0:0:0".equals(s)) {
+ cmd += " " + InetAddress.getByName(s).getHostAddress();
+ }
+ }
+
+ mConnector.doCommand(cmd);
+ } catch (UnknownHostException e) {
+ throw new IllegalStateException("failed to resolve dns address.", e);
+ } catch (NativeDaemonConnectorException e) {
+ throw new IllegalStateException(
+ "Error communicating with native deamon to set dns for interface", e);
+ }
+ }
+
+ public void flushDefaultDnsCache() throws IllegalStateException {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
+ try {
+ String cmd = "resolver flushdefaultif";
+
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ throw new IllegalStateException(
+ "Error communicating with native deamon to flush default interface", e);
+ }
+ }
+
+ public void flushInterfaceDnsCache(String iface) throws IllegalStateException {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
+ try {
+ String cmd = "resolver flushif " + iface;
+
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ throw new IllegalStateException(
+ "Error communicating with native deamon to flush interface " + iface, e);
+ }
+ }
}