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

Commit 397c3379 authored by Jeff Davidson's avatar Jeff Davidson Committed by Android Git Automerger
Browse files

am d0868c89: Implement VpnService.setBlocking().

* commit 'd0868c89eac6df2adbbdcdee7fe24dba943736a7':
  Implement VpnService.setBlocking().
parents b8bf2598 6bbf39cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -577,7 +577,7 @@ public class VpnService extends Service {
         * @return this {@link Builder} object to facilitate chaining method calls.
         * @return this {@link Builder} object to facilitate chaining method calls.
         */
         */
        public Builder setBlocking(boolean blocking) {
        public Builder setBlocking(boolean blocking) {
            // TODO
            mConfig.blocking = blocking;
            return this;
            return this;
        }
        }


+3 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ public class VpnConfig implements Parcelable {
    public PendingIntent configureIntent;
    public PendingIntent configureIntent;
    public long startTime = -1;
    public long startTime = -1;
    public boolean legacy;
    public boolean legacy;
    public boolean blocking;


    public void addLegacyRoutes(String routesStr) {
    public void addLegacyRoutes(String routesStr) {
        if (routesStr.trim().equals("")) {
        if (routesStr.trim().equals("")) {
@@ -120,6 +121,7 @@ public class VpnConfig implements Parcelable {
        out.writeParcelable(configureIntent, flags);
        out.writeParcelable(configureIntent, flags);
        out.writeLong(startTime);
        out.writeLong(startTime);
        out.writeInt(legacy ? 1 : 0);
        out.writeInt(legacy ? 1 : 0);
        out.writeInt(blocking ? 1 : 0);
    }
    }


    public static final Parcelable.Creator<VpnConfig> CREATOR =
    public static final Parcelable.Creator<VpnConfig> CREATOR =
@@ -138,6 +140,7 @@ public class VpnConfig implements Parcelable {
            config.configureIntent = in.readParcelable(null);
            config.configureIntent = in.readParcelable(null);
            config.startTime = in.readLong();
            config.startTime = in.readLong();
            config.legacy = in.readInt() != 0;
            config.legacy = in.readInt() != 0;
            config.blocking = in.readInt() != 0;
            return config;
            return config;
        }
        }


+8 −0
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ import com.android.internal.net.VpnProfile;
import com.android.server.net.BaseNetworkObserver;
import com.android.server.net.BaseNetworkObserver;


import java.io.File;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetAddress;
@@ -470,6 +471,13 @@ public class Vpn {
            if (oldInterface != null && !oldInterface.equals(interfaze)) {
            if (oldInterface != null && !oldInterface.equals(interfaze)) {
                jniReset(oldInterface);
                jniReset(oldInterface);
            }
            }

            try {
                IoUtils.setBlocking(tun.getFileDescriptor(), config.blocking);
            } catch (IOException e) {
                throw new IllegalStateException(
                        "Cannot set tunnel's fd as blocking=" + config.blocking, e);
            }
        } catch (RuntimeException e) {
        } catch (RuntimeException e) {
            IoUtils.closeQuietly(tun);
            IoUtils.closeQuietly(tun);
            agentDisconnect();
            agentDisconnect();