Loading Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ java_library { sdk_version: "system_30", visibility: ["//visibility:private"], lint: { baseline_filename: "lint-baseline-api-30-shims.xml", strict_updatability_linting: true, }, } Loading apishim/30/com/android/networkstack/apishim/api30/CaptivePortalDataShimImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class CaptivePortalDataShimImpl @Override public CaptivePortalDataShim withVenueFriendlyName(String friendlyName) throws UnsupportedApiLevelException { // Not supported in API level 29 // Not supported in API level 30 throw new UnsupportedApiLevelException("FriendlyName not supported on API 30"); } Loading @@ -149,7 +149,7 @@ public class CaptivePortalDataShimImpl public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName, @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) throws UnsupportedApiLevelException { // Not supported in API level 29 // Not supported in API level 30 throw new UnsupportedApiLevelException("PasspointInfo not supported on API 30"); } } apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java +6 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.networkstack.apishim.api30; import static com.android.modules.utils.build.SdkLevel.isAtLeastR; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading @@ -25,17 +27,17 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.annotation.RequiresApi; import com.android.networkstack.apishim.common.CaptivePortalDataShim; import com.android.networkstack.apishim.common.NetworkInformationShim; import com.android.networkstack.apishim.common.ShimUtils; import java.net.Inet4Address; /** * Compatibility implementation of {@link NetworkInformationShim}. */ @RequiresApi(Build.VERSION_CODES.R) public class NetworkInformationShimImpl extends com.android.networkstack.apishim.api29.NetworkInformationShimImpl { private static final String TAG = "api30.NetworkInformationShimImpl"; Loading @@ -45,21 +47,14 @@ public class NetworkInformationShimImpl extends /** * Get a new instance of {@link NetworkInformationShim}. */ @RequiresApi(Build.VERSION_CODES.Q) public static NetworkInformationShim newInstance() { if (!useApiAboveQ()) { if (!isAtLeastR()) { 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) { Loading lint-baseline-api-30-shims.xmldeleted 100644 → 0 +0 −37 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0"> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#getNat64Prefix`" errorLine1=" return lp.getNat64Prefix();" errorLine2=" ~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="85" column="19"/> </issue> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#setNat64Prefix`" errorLine1=" lp.setNat64Prefix(prefix);" errorLine2=" ~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="90" column="12"/> </issue> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#setDhcpServerAddress`" errorLine1=" lp.setDhcpServerAddress(serverAddress);" errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="109" column="12"/> </issue> </issues> tests/unit/src/com/android/networkstack/NetworkStackNotifierTest.kt +11 −9 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ import com.android.networkstack.NetworkStackNotifier.CHANNEL_VENUE_INFO import com.android.networkstack.NetworkStackNotifier.CONNECTED_NOTIFICATION_TIMEOUT_MS import com.android.networkstack.NetworkStackNotifier.Dependencies import com.android.networkstack.apishim.NetworkInformationShimImpl import com.android.modules.utils.build.SdkLevel.isAtLeastR import com.android.modules.utils.build.SdkLevel.isAtLeastS import org.junit.Assume.assumeTrue import org.junit.Before import org.junit.Test Loading Loading @@ -235,7 +237,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedNotification_WithSsid() { // NetworkCapabilities#getSSID is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) val capabilities = NetworkCapabilities(VALIDATED_CAPABILITIES).setSSID(TEST_SSID) onCapabilitiesChanged(EMPTY_CAPABILITIES) Loading @@ -252,7 +254,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading @@ -270,7 +272,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoNotification_VenueInfoDisabled() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) val channel = NotificationChannel(CHANNEL_VENUE_INFO, "test channel", IMPORTANCE_NONE) doReturn(channel).`when`(mNotificationChannelsNm).getNotificationChannel(CHANNEL_VENUE_INFO) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) Loading @@ -289,7 +291,7 @@ class NetworkStackNotifierTest { @Test fun testVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) val capabilities = NetworkCapabilities(VALIDATED_CAPABILITIES).setSSID(TEST_SSID) Loading @@ -307,7 +309,7 @@ class NetworkStackNotifierTest { @Test fun testVenueInfoNotification_VenueInfoDisabled() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) doReturn(null).`when`(mNm).getNotificationChannel(CHANNEL_VENUE_INFO) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading @@ -320,7 +322,7 @@ class NetworkStackNotifierTest { @Test fun testNonDefaultVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onCapabilitiesChanged(VALIDATED_CAPABILITIES) mLooper.processAllMessages() Loading @@ -331,7 +333,7 @@ class NetworkStackNotifierTest { @Test fun testEmptyCaptivePortalDataVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(EMPTY_CAPPORT_LP) onCapabilitiesChanged(VALIDATED_CAPABILITIES) mLooper.processAllMessages() Loading @@ -342,7 +344,7 @@ class NetworkStackNotifierTest { @Test fun testUnvalidatedNetworkVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onCapabilitiesChanged(EMPTY_CAPABILITIES) mLooper.processAllMessages() Loading @@ -353,7 +355,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoWithFriendlyNameNotification() { // Venue info (CaptivePortalData) with friendly name is not available for API <= R assumeTrue(NetworkInformationShimImpl.useApiAboveR()) assumeTrue(isAtLeastS()) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) onLinkPropertiesChanged(mTestCapportVenueUrlWithFriendlyNameLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading Loading
Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ java_library { sdk_version: "system_30", visibility: ["//visibility:private"], lint: { baseline_filename: "lint-baseline-api-30-shims.xml", strict_updatability_linting: true, }, } Loading
apishim/30/com/android/networkstack/apishim/api30/CaptivePortalDataShimImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class CaptivePortalDataShimImpl @Override public CaptivePortalDataShim withVenueFriendlyName(String friendlyName) throws UnsupportedApiLevelException { // Not supported in API level 29 // Not supported in API level 30 throw new UnsupportedApiLevelException("FriendlyName not supported on API 30"); } Loading @@ -149,7 +149,7 @@ public class CaptivePortalDataShimImpl public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName, @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) throws UnsupportedApiLevelException { // Not supported in API level 29 // Not supported in API level 30 throw new UnsupportedApiLevelException("PasspointInfo not supported on API 30"); } }
apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java +6 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.networkstack.apishim.api30; import static com.android.modules.utils.build.SdkLevel.isAtLeastR; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading @@ -25,17 +27,17 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.annotation.RequiresApi; import com.android.networkstack.apishim.common.CaptivePortalDataShim; import com.android.networkstack.apishim.common.NetworkInformationShim; import com.android.networkstack.apishim.common.ShimUtils; import java.net.Inet4Address; /** * Compatibility implementation of {@link NetworkInformationShim}. */ @RequiresApi(Build.VERSION_CODES.R) public class NetworkInformationShimImpl extends com.android.networkstack.apishim.api29.NetworkInformationShimImpl { private static final String TAG = "api30.NetworkInformationShimImpl"; Loading @@ -45,21 +47,14 @@ public class NetworkInformationShimImpl extends /** * Get a new instance of {@link NetworkInformationShim}. */ @RequiresApi(Build.VERSION_CODES.Q) public static NetworkInformationShim newInstance() { if (!useApiAboveQ()) { if (!isAtLeastR()) { 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) { Loading
lint-baseline-api-30-shims.xmldeleted 100644 → 0 +0 −37 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0"> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#getNat64Prefix`" errorLine1=" return lp.getNat64Prefix();" errorLine2=" ~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="85" column="19"/> </issue> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#setNat64Prefix`" errorLine1=" lp.setNat64Prefix(prefix);" errorLine2=" ~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="90" column="12"/> </issue> <issue id="NewApi" message="Call requires API level R (current min is 29): `android.net.LinkProperties#setDhcpServerAddress`" errorLine1=" lp.setDhcpServerAddress(serverAddress);" errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> <location file="packages/modules/NetworkStack/apishim/30/com/android/networkstack/apishim/api30/NetworkInformationShimImpl.java" line="109" column="12"/> </issue> </issues>
tests/unit/src/com/android/networkstack/NetworkStackNotifierTest.kt +11 −9 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ import com.android.networkstack.NetworkStackNotifier.CHANNEL_VENUE_INFO import com.android.networkstack.NetworkStackNotifier.CONNECTED_NOTIFICATION_TIMEOUT_MS import com.android.networkstack.NetworkStackNotifier.Dependencies import com.android.networkstack.apishim.NetworkInformationShimImpl import com.android.modules.utils.build.SdkLevel.isAtLeastR import com.android.modules.utils.build.SdkLevel.isAtLeastS import org.junit.Assume.assumeTrue import org.junit.Before import org.junit.Test Loading Loading @@ -235,7 +237,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedNotification_WithSsid() { // NetworkCapabilities#getSSID is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) val capabilities = NetworkCapabilities(VALIDATED_CAPABILITIES).setSSID(TEST_SSID) onCapabilitiesChanged(EMPTY_CAPABILITIES) Loading @@ -252,7 +254,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading @@ -270,7 +272,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoNotification_VenueInfoDisabled() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) val channel = NotificationChannel(CHANNEL_VENUE_INFO, "test channel", IMPORTANCE_NONE) doReturn(channel).`when`(mNotificationChannelsNm).getNotificationChannel(CHANNEL_VENUE_INFO) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) Loading @@ -289,7 +291,7 @@ class NetworkStackNotifierTest { @Test fun testVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) val capabilities = NetworkCapabilities(VALIDATED_CAPABILITIES).setSSID(TEST_SSID) Loading @@ -307,7 +309,7 @@ class NetworkStackNotifierTest { @Test fun testVenueInfoNotification_VenueInfoDisabled() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) doReturn(null).`when`(mNm).getNotificationChannel(CHANNEL_VENUE_INFO) onLinkPropertiesChanged(mTestCapportLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading @@ -320,7 +322,7 @@ class NetworkStackNotifierTest { @Test fun testNonDefaultVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onCapabilitiesChanged(VALIDATED_CAPABILITIES) mLooper.processAllMessages() Loading @@ -331,7 +333,7 @@ class NetworkStackNotifierTest { @Test fun testEmptyCaptivePortalDataVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(EMPTY_CAPPORT_LP) onCapabilitiesChanged(VALIDATED_CAPABILITIES) mLooper.processAllMessages() Loading @@ -342,7 +344,7 @@ class NetworkStackNotifierTest { @Test fun testUnvalidatedNetworkVenueInfoNotification() { // Venue info (CaptivePortalData) is not available for API <= Q assumeTrue(NetworkInformationShimImpl.useApiAboveQ()) assumeTrue(isAtLeastR()) onLinkPropertiesChanged(mTestCapportLp) onCapabilitiesChanged(EMPTY_CAPABILITIES) mLooper.processAllMessages() Loading @@ -353,7 +355,7 @@ class NetworkStackNotifierTest { @Test fun testConnectedVenueInfoWithFriendlyNameNotification() { // Venue info (CaptivePortalData) with friendly name is not available for API <= R assumeTrue(NetworkInformationShimImpl.useApiAboveR()) assumeTrue(isAtLeastS()) mNotifier.notifyCaptivePortalValidationPending(TEST_NETWORK) onLinkPropertiesChanged(mTestCapportVenueUrlWithFriendlyNameLp) onDefaultNetworkAvailable(TEST_NETWORK) Loading