Loading apishim/29/com/android/networkstack/apishim/api29/CaptivePortalDataShimImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading Loading @@ -48,8 +50,25 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } @Override public String getVenueFriendlyName() { // Not supported in API level 29 return null; } @VisibleForTesting public static boolean isSupported() { return false; } /** * 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 */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { // Not supported in API level 29 return null; } } apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java +22 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading Loading @@ -57,6 +58,14 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { return false; } /** * Indicates whether the shim can use APIs above the R SDK. */ @VisibleForTesting public static boolean useApiAboveR() { return false; } @Nullable @Override public Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp) { Loading Loading @@ -105,4 +114,17 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { @NonNull Inet4Address serverAddress) { // Not supported on this API level: no-op } /** * Set captive portal data in {@link LinkProperties} * @param lp Link properties object to be updated * @param captivePortalData Captive portal data to be used */ public void setCaptivePortalData(@NonNull LinkProperties lp, @Nullable CaptivePortalData captivePortalData) { if (lp == null) { return; } lp.setCaptivePortalData(captivePortalData); } } apishim/30/com/android/networkstack/apishim/api30/CaptivePortalDataShimImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ import org.json.JSONObject; public class CaptivePortalDataShimImpl extends com.android.networkstack.apishim.api29.CaptivePortalDataShimImpl { @NonNull private final CaptivePortalData mData; protected final CaptivePortalData mData; protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) { mData = data; Loading apishim/31/com/android/networkstack/apishim/CaptivePortalDataShimImpl.java +19 −1 Original line number Diff line number Diff line Loading @@ -20,13 +20,31 @@ import android.net.CaptivePortalData; import androidx.annotation.NonNull; import com.android.networkstack.apishim.common.CaptivePortalDataShim; /** * Compatibility implementation of {@link CaptivePortalDataShim}. */ public class CaptivePortalDataShimImpl extends com.android.networkstack.apishim.api30.CaptivePortalDataShimImpl { // Currently, this is the same as the API 30 shim, so inherit everything from that. protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) { super(data); } @Override public String getVenueFriendlyName() { return mData.getVenueFriendlyName(); } /** * 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 */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { return new CaptivePortalData.Builder(mData) .setVenueFriendlyName(friendlyName) .build(); } } apishim/31/com/android/networkstack/apishim/NetworkInformationShimImpl.java +35 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,45 @@ package com.android.networkstack.apishim; import android.net.LinkProperties; import android.os.Build; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.networkstack.apishim.common.CaptivePortalDataShim; import com.android.networkstack.apishim.common.NetworkInformationShim; import com.android.networkstack.apishim.common.ShimUtils; /** * Compatibility implementation of {@link NetworkInformationShim}. */ public class NetworkInformationShimImpl extends com.android.networkstack.apishim.api30.NetworkInformationShimImpl { // Currently, this is the same as the API 30 shim, so inherit everything from that. protected NetworkInformationShimImpl() {} /** * Indicates whether the shim can use APIs above the R SDK. */ @VisibleForTesting public static boolean useApiAboveR() { return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R); } /** * Get a new instance of {@link NetworkInformationShim}. */ public static NetworkInformationShim newInstance() { if (!useApiAboveR()) { return com.android.networkstack.apishim.api30.NetworkInformationShimImpl.newInstance(); } return new com.android.networkstack.apishim.NetworkInformationShimImpl(); } @Nullable @Override public CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp) { if (lp == null || lp.getCaptivePortalData() == null) return null; return new CaptivePortalDataShimImpl(lp.getCaptivePortalData()); } } Loading
apishim/29/com/android/networkstack/apishim/api29/CaptivePortalDataShimImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading Loading @@ -48,8 +50,25 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } @Override public String getVenueFriendlyName() { // Not supported in API level 29 return null; } @VisibleForTesting public static boolean isSupported() { return false; } /** * 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 */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { // Not supported in API level 29 return null; } }
apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java +22 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading Loading @@ -57,6 +58,14 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { return false; } /** * Indicates whether the shim can use APIs above the R SDK. */ @VisibleForTesting public static boolean useApiAboveR() { return false; } @Nullable @Override public Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp) { Loading Loading @@ -105,4 +114,17 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { @NonNull Inet4Address serverAddress) { // Not supported on this API level: no-op } /** * Set captive portal data in {@link LinkProperties} * @param lp Link properties object to be updated * @param captivePortalData Captive portal data to be used */ public void setCaptivePortalData(@NonNull LinkProperties lp, @Nullable CaptivePortalData captivePortalData) { if (lp == null) { return; } lp.setCaptivePortalData(captivePortalData); } }
apishim/30/com/android/networkstack/apishim/api30/CaptivePortalDataShimImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ import org.json.JSONObject; public class CaptivePortalDataShimImpl extends com.android.networkstack.apishim.api29.CaptivePortalDataShimImpl { @NonNull private final CaptivePortalData mData; protected final CaptivePortalData mData; protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) { mData = data; Loading
apishim/31/com/android/networkstack/apishim/CaptivePortalDataShimImpl.java +19 −1 Original line number Diff line number Diff line Loading @@ -20,13 +20,31 @@ import android.net.CaptivePortalData; import androidx.annotation.NonNull; import com.android.networkstack.apishim.common.CaptivePortalDataShim; /** * Compatibility implementation of {@link CaptivePortalDataShim}. */ public class CaptivePortalDataShimImpl extends com.android.networkstack.apishim.api30.CaptivePortalDataShimImpl { // Currently, this is the same as the API 30 shim, so inherit everything from that. protected CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) { super(data); } @Override public String getVenueFriendlyName() { return mData.getVenueFriendlyName(); } /** * 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 */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { return new CaptivePortalData.Builder(mData) .setVenueFriendlyName(friendlyName) .build(); } }
apishim/31/com/android/networkstack/apishim/NetworkInformationShimImpl.java +35 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,45 @@ package com.android.networkstack.apishim; import android.net.LinkProperties; import android.os.Build; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.networkstack.apishim.common.CaptivePortalDataShim; import com.android.networkstack.apishim.common.NetworkInformationShim; import com.android.networkstack.apishim.common.ShimUtils; /** * Compatibility implementation of {@link NetworkInformationShim}. */ public class NetworkInformationShimImpl extends com.android.networkstack.apishim.api30.NetworkInformationShimImpl { // Currently, this is the same as the API 30 shim, so inherit everything from that. protected NetworkInformationShimImpl() {} /** * Indicates whether the shim can use APIs above the R SDK. */ @VisibleForTesting public static boolean useApiAboveR() { return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R); } /** * Get a new instance of {@link NetworkInformationShim}. */ public static NetworkInformationShim newInstance() { if (!useApiAboveR()) { return com.android.networkstack.apishim.api30.NetworkInformationShimImpl.newInstance(); } return new com.android.networkstack.apishim.NetworkInformationShimImpl(); } @Nullable @Override public CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp) { if (lp == null || lp.getCaptivePortalData() == null) return null; return new CaptivePortalDataShimImpl(lp.getCaptivePortalData()); } }