From 934d483e4b6f096fc1c4241fcee3296144d27d57 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Thu, 22 Feb 2024 11:21:47 +0800 Subject: [PATCH] Bump the required SDK level to U for isUidNetworkingBlocked This change is a follow-up from aosp/2970991. The kernel bug can trigger crashes on some T devices. Therefore, bumping the required API level is necessary. No CTS modification since the check doesn't exist in pre-U CTS releases. Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests Bug: 326143935 Change-Id: I63796f25315ee9f966dd5bf0afd2240b1ed456e1 --- framework/src/android/net/ConnectivityManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java index 1ea181593d..915ec52e77 100644 --- a/framework/src/android/net/ConnectivityManager.java +++ b/framework/src/android/net/ConnectivityManager.java @@ -74,6 +74,7 @@ import android.util.Range; import android.util.SparseIntArray; import com.android.internal.annotations.GuardedBy; +import com.android.modules.utils.build.SdkLevel; import libcore.net.event.NetworkEventDispatcher; @@ -6278,9 +6279,13 @@ public class ConnectivityManager { // Only the system server process and the network stack have access. @FlaggedApi(Flags.SUPPORT_IS_UID_NETWORKING_BLOCKED) @SystemApi(client = MODULE_LIBRARIES) - @RequiresApi(Build.VERSION_CODES.TIRAMISU) // BPF maps were only mainlined in T + // Note b/326143935 kernel bug can trigger crash on some T device. + @RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE) @RequiresPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public boolean isUidNetworkingBlocked(int uid, boolean isNetworkMetered) { + if (!SdkLevel.isAtLeastU()) { + Log.wtf(TAG, "isUidNetworkingBlocked is not supported on pre-U devices"); + } final BpfNetMapsReader reader = BpfNetMapsReader.getInstance(); // Note that before V, the data saver status in bpf is written by ConnectivityService // when receiving {@link #ACTION_RESTRICT_BACKGROUND_CHANGED}. Thus,