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

Commit fab704eb authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Add shims for setLegacyLockdownVpnEnabled, setRequireVpnForUids.

Bug: 165835257
Test: CTS test CL in same topic.
Change-Id: I1860c4df61e12087345ae723b4b3201d7575664a
parent 83a64b86
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -22,12 +22,15 @@ import android.net.ConnectivityManager.NetworkCallback;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.Handler;
import android.util.Range;

import androidx.annotation.NonNull;

import com.android.networkstack.apishim.common.ConnectivityManagerShim;
import com.android.networkstack.apishim.common.ShimUtils;

import java.util.Collection;

/**
 * Implementation of {@link ConnectivityManagerShim} for API 31.
 */
@@ -77,4 +80,20 @@ public class ConnectivityManagerShimImpl
            int uid, @NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
        mCm.registerDefaultNetworkCallbackAsUid(uid, networkCallback, handler);
    }

    /**
     * See android.net.ConnectivityManager#setLegacyLockdownVpnEnabled
     */
    @Override
    public void setLegacyLockdownVpnEnabled(boolean enabled) {
        mCm.setLegacyLockdownVpnEnabled(enabled);
    }

    /**
     * See android.net.ConnectivityManager#setRequireVpnForUids
     */
    @Override
    public void setRequireVpnForUids(boolean requireVpn, Collection<Range<Integer>> ranges) {
        mCm.setRequireVpnForUids(requireVpn, ranges);
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -19,9 +19,12 @@ package com.android.networkstack.apishim.common;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.NetworkRequest;
import android.os.Handler;
import android.util.Range;

import androidx.annotation.NonNull;

import java.util.Collection;

/**
 * Interface used to access API methods in {@link android.net.ConnectivityManager}, with
 * appropriate fallbacks if the methods are not yet part of the released API.
@@ -48,4 +51,15 @@ public interface ConnectivityManagerShim {
            throws UnsupportedApiLevelException {
        throw new UnsupportedApiLevelException("Only supported starting from API 31");
    }

    /** See android.net.ConnectivityManager#setLegacyLockdownVpnEnabled */
    default void setLegacyLockdownVpnEnabled(boolean enabled) throws UnsupportedApiLevelException {
        throw new UnsupportedApiLevelException("Only supported starting from API 31");
    }

    /** See android.net.ConnectivityManager#setRequireVpnForUids */
    default void setRequireVpnForUids(boolean requireVpn, Collection<Range<Integer>> ranges)
            throws UnsupportedApiLevelException {
        throw new UnsupportedApiLevelException("Only supported starting from API 31");
    }
}