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

Commit 5478c668 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Automerger Merge Worker
Browse files

Merge "Stop using CaptivePortalData in the shim interfaces." am: ee6648c4

Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/1598153

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I573bd87dec4b220930b0c3541809fdca64552143
parents 0e0f1718 ee6648c4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.networkstack.apishim.api29;

import android.net.CaptivePortalData;
import android.net.Uri;

import androidx.annotation.NonNull;
@@ -75,7 +74,7 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim
     * @return a {@link CaptivePortalData} object with a friendly name set
     */
    @Override
    public CaptivePortalData withVenueFriendlyName(String friendlyName)
    public CaptivePortalDataShim withVenueFriendlyName(String friendlyName)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
        throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29");
@@ -93,7 +92,7 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
    public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
+2 −6
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.networkstack.apishim.api29;

import android.net.CaptivePortalData;
import android.net.IpPrefix;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
@@ -121,10 +120,7 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
     * @param captivePortalData Captive portal data to be used
     */
    public void setCaptivePortalData(@NonNull LinkProperties lp,
            @Nullable CaptivePortalData captivePortalData) {
        if (lp == null) {
            return;
        }
        lp.setCaptivePortalData(captivePortalData);
            @Nullable CaptivePortalDataShim captivePortalData) {
        // Not supported on this API level: no-op
    }
}
+12 −8
Original line number Diff line number Diff line
@@ -39,10 +39,14 @@ public class CaptivePortalDataShimImpl
    @NonNull
    protected final CaptivePortalData mData;

    protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) {
    public CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) {
        mData = data;
    }

    public CaptivePortalData getData() {
        return mData;
    }

    /**
     * Parse a {@link CaptivePortalDataShim} from a JSON object.
     * @throws JSONException The JSON is not a representation of correct captive portal data.
@@ -118,31 +122,31 @@ public class CaptivePortalDataShimImpl
    }

    /**
     * Generate a {@link CaptivePortalData} object with a friendly name set
     * Generate a {@link CaptivePortalDataShim} object with a friendly name set
     *
     * @param friendlyName The friendly name to set
     * @return a {@link CaptivePortalData} object with a friendly name set
     * @return a {@link CaptivePortalDataShim} object with a friendly name set
     */
    @Override
    public CaptivePortalData withVenueFriendlyName(String friendlyName)
    public CaptivePortalDataShim withVenueFriendlyName(String friendlyName)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
        throw new UnsupportedApiLevelException("FriendlyName not supported on API 30");
    }

    /**
     * Generate a {@link CaptivePortalData} object with a friendly name and Passpoint external URLs
     * set
     * Generate a {@link CaptivePortalDataShim} object with a friendly name and Passpoint external
     * URLs set
     *
     * @param friendlyName The friendly name to set
     * @param venueInfoUrl Venue information URL
     * @param termsAndConditionsUrl Terms and conditions URL
     *
     * @return a {@link CaptivePortalData} object with friendly name, venue info URL and terms
     * @return a {@link CaptivePortalDataShim} object with friendly name, venue info URL and terms
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
    public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
+9 −0
Original line number Diff line number Diff line
@@ -105,4 +105,13 @@ public class NetworkInformationShimImpl extends
            @NonNull Inet4Address serverAddress) {
        lp.setDhcpServerAddress(serverAddress);
    }

    @Override
    public void setCaptivePortalData(@NonNull LinkProperties lp,
            @Nullable CaptivePortalDataShim captivePortalData) {
        if (lp == null) {
            return;
        }
        lp.setCaptivePortalData(((CaptivePortalDataShimImpl) captivePortalData).getData());
    }
}
+11 −11
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import com.android.networkstack.apishim.common.CaptivePortalDataShim;
 */
public class CaptivePortalDataShimImpl
        extends com.android.networkstack.apishim.api30.CaptivePortalDataShimImpl {
    protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) {
    public CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) {
        super(data);
    }

@@ -47,37 +47,37 @@ public class CaptivePortalDataShimImpl
    }

    /**
     * Generate a {@link CaptivePortalData} object with a friendly name set
     * Generate a {@link CaptivePortalDataShim} object with a friendly name set
     *
     * @param friendlyName The friendly name to set
     * @return a {@link CaptivePortalData} object with a friendly name set
     * @return a {@link CaptivePortalDataShim} object with a friendly name set
     */
    @Override
    public CaptivePortalData withVenueFriendlyName(String friendlyName) {
        return new CaptivePortalData.Builder(mData)
    public CaptivePortalDataShim withVenueFriendlyName(String friendlyName) {
        return new CaptivePortalDataShimImpl(new CaptivePortalData.Builder(mData)
                .setVenueFriendlyName(friendlyName)
                .build();
                .build());
    }

    /**
     * Generate a {@link CaptivePortalData} object with a friendly name and Passpoint external
     * Generate a {@link CaptivePortalDataShim} object with a friendly name and Passpoint external
     * URLs set
     *
     * @param friendlyName The friendly name to set
     * @param venueInfoUrl Venue information URL
     * @param termsAndConditionsUrl Terms and conditions URL
     *
     * @return a {@link CaptivePortalData} object with friendly name, venue info URL and terms
     * @return a {@link CaptivePortalDataShim} object with friendly name, venue info URL and terms
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
    public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) {
        return new CaptivePortalData.Builder(mData)
        return new CaptivePortalDataShimImpl(new CaptivePortalData.Builder(mData)
                .setVenueFriendlyName(friendlyName)
                .setVenueInfoUrl(venueInfoUrl, ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
                .setUserPortalUrl(termsAndConditionsUrl,
                        ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
                .build();
                .build());
    }
}
Loading