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

Commit 1b117cef authored by Hai Shalom's avatar Hai Shalom Committed by Automerger Merge Worker
Browse files

Merge "Support for Terms & Conditions notification" am: f5962f27

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2751a125fc2427996df73f3ca74cfb14ef63da52
parents af9f2e48 f5962f27
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.networkstack.apishim.api29;

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

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -56,6 +57,12 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim
        return null;
    }

    @Override
    public int getUserPortalUrlSource() {
        // Not supported in API level 29
        return ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_OTHER;
    }

    @VisibleForTesting
    public static boolean isSupported() {
        return false;
@@ -67,8 +74,29 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim
     * @param friendlyName The friendly name to set
     * @return a {@link CaptivePortalData} object with a friendly name set
     */
    public CaptivePortalData withVenueFriendlyName(String friendlyName) {
    @Override
    public CaptivePortalData withVenueFriendlyName(String friendlyName)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
        return null;
        throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29");
    }

    /**
     * Generate a {@link CaptivePortalData} 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
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
        throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29");
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -34,4 +34,8 @@ public class ConstantsShim {
    // Constants defined in android.net.ConnectivityDiagnosticsManager.
    public static final int DETECTION_METHOD_DNS_EVENTS = 1;
    public static final int DETECTION_METHOD_TCP_METRICS = 2;

    // Constants defined in android.net.CaptivePortalData.
    public static final int CAPTIVE_PORTAL_DATA_SOURCE_OTHER = 0;
    public static final int CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT = 1;
}
+32 −0
Original line number Diff line number Diff line
@@ -116,4 +116,36 @@ public class CaptivePortalDataShimImpl
    public void notifyChanged(INetworkMonitorCallbacks cb) throws RemoteException {
        cb.notifyCaptivePortalDataChanged(mData);
    }

    /**
     * Generate a {@link CaptivePortalData} object with a friendly name set
     *
     * @param friendlyName The friendly name to set
     * @return a {@link CaptivePortalData} object with a friendly name set
     */
    @Override
    public CaptivePortalData 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
     *
     * @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
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)
            throws UnsupportedApiLevelException {
        // Not supported in API level 29
        throw new UnsupportedApiLevelException("PasspointInfo not supported on API 30");
    }
}
+33 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.networkstack.apishim;

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

import androidx.annotation.NonNull;

@@ -36,15 +37,47 @@ public class CaptivePortalDataShimImpl
        return mData.getVenueFriendlyName();
    }

    /**
     * Get the information source of the User portal
     * @return The source that the User portal was obtained from
     */
    @Override
    public int getUserPortalUrlSource() {
        return mData.getUserPortalUrlSource();
    }

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

    /**
     * Generate a {@link CaptivePortalData} 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
     * and conditions URL set
     */
    @Override
    public CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) {
        return new CaptivePortalData.Builder(mData)
                .setVenueFriendlyName(friendlyName)
                .setVenueInfoUrl(venueInfoUrl, ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
                .setUserPortalUrl(termsAndConditionsUrl,
                        ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
                .build();
    }
}
+24 −1
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ public interface CaptivePortalDataShim {
     */
    String getVenueFriendlyName();

    /**
     * @see CaptivePortalData#getUserPortalUrlSource()
     */
    int getUserPortalUrlSource();

    /**
     * @see INetworkMonitorCallbacks#notifyCaptivePortalDataChanged(android.net.CaptivePortalData)
     */
@@ -65,7 +70,25 @@ public interface CaptivePortalDataShim {
     * Generate a {@link CaptivePortalData} object with a friendly name set
     *
     * @param friendlyName The friendly name to set
     * @throws UnsupportedApiLevelException when used with API level lower than 31
     * @return a {@link CaptivePortalData} object with a friendly name set
     */
    CaptivePortalData withVenueFriendlyName(@NonNull String friendlyName);
    CaptivePortalData withVenueFriendlyName(@NonNull String friendlyName)
            throws UnsupportedApiLevelException;

    /**
     * Generate a {@link CaptivePortalData} 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
     *
     * @throws UnsupportedApiLevelException when used with API level lower than 31
     * @return a {@link CaptivePortalData} object with friendly name, venue info URL and terms
     * and conditions URL set
     */
    CaptivePortalData withPasspointInfo(@NonNull String friendlyName,
            @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)
            throws UnsupportedApiLevelException;
}
Loading