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

Commit 51019a0f authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Android (Google) Code Review
Browse files

Merge "Expose clatd commands to NetworkManagementService." into jb-mr2-dev

parents 1361dff5 79751848
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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();
}
+39 −0
Original line number Diff line number Diff line
@@ -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() {