Merge "Expose clatd commands to NetworkManagementService." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
51019a0fc7
@@ -362,4 +362,19 @@ interface INetworkManagementService
|
||||
* Clear a process (pid) from being associated with an interface.
|
||||
*/
|
||||
void clearDnsInterfaceForPid(int pid);
|
||||
|
||||
/**
|
||||
* Start the clatd (464xlat) service
|
||||
*/
|
||||
void startClatd(String interfaceName);
|
||||
|
||||
/**
|
||||
* Stop the clatd (464xlat) service
|
||||
*/
|
||||
void stopClatd();
|
||||
|
||||
/**
|
||||
* Determine whether the clatd (464xlat) service has been started
|
||||
*/
|
||||
boolean isClatdStarted();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import static android.net.NetworkStats.SET_DEFAULT;
|
||||
import static android.net.NetworkStats.TAG_NONE;
|
||||
import static android.net.NetworkStats.UID_ALL;
|
||||
import static android.net.TrafficStats.UID_TETHERING;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.ClatdStatusResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceGetCfgResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.IpFwdStatusResult;
|
||||
@@ -122,6 +123,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
public static final int QuotaCounterResult = 220;
|
||||
public static final int TetheringStatsResult = 221;
|
||||
public static final int DnsProxyQueryResult = 222;
|
||||
public static final int ClatdStatusResult = 223;
|
||||
|
||||
public static final int InterfaceChange = 600;
|
||||
public static final int BandwidthControl = 601;
|
||||
@@ -1498,6 +1500,43 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startClatd(String interfaceName) throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||
|
||||
try {
|
||||
mConnector.execute("clatd", "start", interfaceName);
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopClatd() throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||
|
||||
try {
|
||||
mConnector.execute("clatd", "stop");
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClatdStarted() {
|
||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||
|
||||
final NativeDaemonEvent event;
|
||||
try {
|
||||
event = mConnector.execute("clatd", "status");
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
|
||||
event.checkCode(ClatdStatusResult);
|
||||
return event.getMessage().endsWith("started");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void monitor() {
|
||||
|
||||
Reference in New Issue
Block a user