Revert "Prepare for @RequiresApi class retention"

This reverts commit 53da9ac34c.
And fixes the linter errors.

Bug: 328190227
Test: TH
Change-Id: I92e0f268c770b6e46bdc781d4867f1e0b505d4ad
This commit is contained in:
Motomu Utsumi 2024-06-13 09:29:47 +00:00
commit a1a0034f0e
7 changed files with 22 additions and 30 deletions

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.4.0-alpha01" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha01">
<issue
id="NewApi"
message="Call requires API level 33 (current min is 30): `getUidRule`"
errorLine1=" return BpfNetMapsReader.getUidRule(sUidOwnerMap, childChain, uid);"
errorLine2=" ~~~~~~~~~~">
<location
file="packages/modules/Connectivity/service/src/com/android/server/BpfNetMaps.java"
line="643"
column="33"/>
</issue>
<issue
id="NewApi"
message="Call requires API level 31 (current min is 30): `BpfBitmap`"

View file

@ -580,6 +580,7 @@ public class BpfNetMaps {
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
*/
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
public int getUidRule(final int childChain, final int uid) {
return BpfNetMapsUtils.getUidRule(sUidOwnerMap, childChain, uid);
}

View file

@ -11754,6 +11754,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
return 0;
}
case "get-package-networking-enabled": {
if (!mDeps.isAtLeastT()) {
throw new UnsupportedOperationException(
"This command is not supported on T-");
}
final String packageName = getNextArg();
final int rule = getPackageFirewallRule(
ConnectivityManager.FIREWALL_CHAIN_OEM_DENY_3, packageName);
@ -11783,6 +11787,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
return 0;
}
case "get-background-networking-enabled-for-uid": {
if (!mDeps.isAtLeastT()) {
throw new UnsupportedOperationException(
"This command is not supported on T-");
}
final Integer uid = parseIntegerArgument(getNextArg());
if (null == uid) {
onHelp();
@ -13830,6 +13838,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private int getPackageFirewallRule(final int chain, final String packageName)
throws PackageManager.NameNotFoundException {
final PackageManager pm = mContext.getPackageManager();
@ -13837,6 +13846,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
return getUidFirewallRule(chain, appId);
}
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Override
public int getUidFirewallRule(final int chain, final int uid) {
enforceNetworkStackOrSettingsPermission();

View file

@ -280,7 +280,7 @@ java_library {
"//apex_available:platform",
],
lint: {
baseline_filename: "lint-baseline.xml",
strict_updatability_linting: true,
error_checks: ["NewApi"],
},
}

View file

@ -19,8 +19,7 @@ package com.android.net.module.util;
import static android.net.util.SocketUtils.closeSocket;
import android.annotation.NonNull;
import android.annotation.RequiresApi;
import android.os.Build;
import android.annotation.SuppressLint;
import android.system.NetlinkSocketAddress;
import java.io.FileDescriptor;
@ -41,7 +40,11 @@ public class SocketUtils {
/**
* Make a socket address to communicate with netlink.
*/
@NonNull @RequiresApi(Build.VERSION_CODES.S)
// NetlinkSocketAddress was CorePlatformApi on R and linter warns this is available on S+.
// android.net.util.SocketUtils.makeNetlinkSocketAddress can be used instead, but this method
// has been used on R, so suppress the linter and keep as it is.
@SuppressLint("NewApi")
@NonNull
public static SocketAddress makeNetlinkSocketAddress(int portId, int groupsMask) {
return new NetlinkSocketAddress(portId, groupsMask);
}

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.4.0-alpha04" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha04">
<issue
id="NewApi"
message="Call requires API level 31 (current min is 30): `makeNetlinkSocketAddress`"
errorLine1=" Os.bind(fd, makeNetlinkSocketAddress(0, mBindGroups));"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="packages/modules/Connectivity/staticlibs/device/com/android/net/module/util/ip/NetlinkMonitor.java"
line="111"
column="25"/>
</issue>
</issues>

View file

@ -39,6 +39,7 @@ android_library {
"//packages/modules/NetworkStack/tests/integration",
],
lint: {
strict_updatability_linting: true,
test: true,
},
}
@ -56,4 +57,7 @@ android_test {
],
jarjar_rules: "jarjar-rules.txt",
test_suites: ["device-tests"],
lint: {
strict_updatability_linting: true,
},
}