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

Commit b0da42f1 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6224475 from 9da6624d to rvc-release

Change-Id: I7bf8ecf84f2b78b1f33bf15de33304c6b610cd5b
parents f2ce3dd6 9da6624d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.net.Uri;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.networkstack.apishim.CaptivePortalDataShim;
import com.android.networkstack.apishim.NetworkInformationShim;

/**
@@ -44,6 +46,14 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
        return new NetworkInformationShimImpl();
    }

    /**
     * Indicates whether the shim can use APIs above the Q SDK.
     */
    @VisibleForTesting
    public static boolean useApiAboveQ() {
        return false;
    }

    @Nullable
    @Override
    public Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp) {
@@ -56,10 +66,22 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
        // Not supported on this API level: no-op
    }

    @Nullable
    @Override
    public CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp) {
        return null;
    }

    @Nullable
    @Override
    public String getSSID(@Nullable NetworkCapabilities nc) {
        // Not supported on this API level
        return null;
    }

    @NonNull
    @Override
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return new LinkProperties(lp);
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.Build;
import android.os.RemoteException;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

import org.json.JSONException;
import org.json.JSONObject;
@@ -70,7 +69,6 @@ public class CaptivePortalDataShimImpl
                .build());
    }

    @VisibleForTesting
    public static boolean isSupported() {
        return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q);
    }
@@ -95,6 +93,11 @@ public class CaptivePortalDataShimImpl
        return mData.getUserPortalUrl();
    }

    @Override
    public Uri getVenueInfoUrl() {
        return mData.getVenueInfoUrl();
    }

    @Override
    public void notifyChanged(INetworkMonitorCallbacks cb) throws RemoteException {
        cb.notifyCaptivePortalDataChanged(mData);
+23 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

/**
 * Compatibility implementation of {@link NetworkInformationShim}.
@@ -35,12 +36,20 @@ public class NetworkInformationShimImpl extends
     * Get a new instance of {@link NetworkInformationShim}.
     */
    public static NetworkInformationShim newInstance() {
        if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
        if (!useApiAboveQ()) {
            return com.android.networkstack.apishim.api29.NetworkInformationShimImpl.newInstance();
        }
        return new NetworkInformationShimImpl();
    }

    /**
     * Indicates whether the shim can use APIs above the Q SDK.
     */
    @VisibleForTesting
    public static boolean useApiAboveQ() {
        return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q);
    }

    @Nullable
    @Override
    public Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp) {
@@ -53,10 +62,23 @@ public class NetworkInformationShimImpl extends
        lp.setCaptivePortalApiUrl(url);
    }

    @Nullable
    @Override
    public CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp) {
        if (lp == null || lp.getCaptivePortalData() == null) return null;
        return new CaptivePortalDataShimImpl(lp.getCaptivePortalData());
    }

    @Nullable
    @Override
    public String getSSID(@Nullable NetworkCapabilities nc) {
        if (nc == null) return null;
        return nc.getSSID();
    }

    @NonNull
    @Override
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return lp.makeSensitiveFieldsParcelingCopy();
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@ public interface CaptivePortalDataShim {
     */
    Uri getUserPortalUrl();

    /**
     * @see android.net.CaptivePortalData#getVenueInfoUrl()
     */
    Uri getVenueInfoUrl();

    /**
     * @see INetworkMonitorCallbacks#notifyCaptivePortalDataChanged(android.net.CaptivePortalData)
     */
+12 −0
Original line number Diff line number Diff line
@@ -39,9 +39,21 @@ public interface NetworkInformationShim {
     */
    void setCaptivePortalApiUrl(@NonNull LinkProperties lp, @Nullable Uri url);

    /**
     * @see LinkProperties#getCaptivePortalData()
     */
    @Nullable
    CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp);

    /**
     * @see NetworkCapabilities#getSSID()
     */
    @Nullable
    String getSSID(@Nullable NetworkCapabilities nc);

    /**
     * @see LinkProperties#makeSensitiveFieldsParcelingCopy()
     */
    @NonNull
    LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull LinkProperties lp);
}
Loading