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

Commit 6549ebff authored by Colin Cross's avatar Colin Cross
Browse files

Annotate NetworkInformationShimImpl for api 31 with @RequiresApi(S)

An update to lint finds a new error:
packages/modules/NetworkStack/apishim/31/com/android/networkstack/apishim/api31/NetworkInformationShimImpl.java:35: Error: Extending NetworkInformationShimImpl requires API level 30 (current min is 29): NetworkInformationShimImpl [NewApi]
        extends com.android.networkstack.apishim.api30.NetworkInformationShimImpl {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Annotate api31.NetworkInformationShimImpl with @RequiresApi(S).

Also remove the unnecesary useApiAboveR and useApiAboveQ.

Test: m lint-check
Change-Id: Ib86978557972e6ee8d0288770e7cb8fc758a6219
Merged-In: Ib86978557972e6ee8d0288770e7cb8fc758a6219
parent ebc22a81
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.net.Uri;

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

import com.android.networkstack.apishim.common.CaptivePortalDataShim;
import com.android.networkstack.apishim.common.NetworkInformationShim;
@@ -49,22 +48,6 @@ 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;
    }

    /**
     * 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) {
+5 −12
Original line number Diff line number Diff line
@@ -16,38 +16,32 @@

package com.android.networkstack.apishim.api31;

import static com.android.modules.utils.build.SdkLevel.isAtLeastS;

import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.os.Build;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
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}.
 */
@RequiresApi(Build.VERSION_CODES.S)
public class NetworkInformationShimImpl
        extends com.android.networkstack.apishim.api30.NetworkInformationShimImpl {
    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}.
     */
    @RequiresApi(Build.VERSION_CODES.Q)
    public static NetworkInformationShim newInstance() {
        if (!useApiAboveR()) {
        if (!isAtLeastS()) {
            return com.android.networkstack.apishim.api30.NetworkInformationShimImpl.newInstance();
        }
        return new NetworkInformationShimImpl();
@@ -60,7 +54,6 @@ public class NetworkInformationShimImpl
        return new CaptivePortalDataShimImpl(lp.getCaptivePortalData());
    }

    @RequiresApi(Build.VERSION_CODES.S)
    @Nullable
    @Override
    public String getCapabilityCarrierName(int capability) {