From 9e75aad888b9af95afd75dec17fb4c00efbfa7bd Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Wed, 24 Apr 2024 17:39:47 +0900 Subject: [PATCH] Add blocked reason for OEM deny firewall chains FIREWALL_CHAIN_OEM_DENY_x chains were added by aosp/2114533 but corresponding blocked reasons were not added. Upcoming aosp/3027488 updates CS to generate blocked reasons based on bpf map contents. Without blocked reasons for oem deny chains, onBlockedStatusChanged callback will have inconsistency from the actual network blocked status. This CL adds BLOCKED_REASON_OEM_DENY for FIREWALL_CHAIN_OEM_DENY_x chains Bug: 328732146 Test: TH Change-Id: I3793aa0e231d32fea5eb202ed69e170f74d66b02 --- common/flags.aconfig | 8 ++++++++ framework/api/module-lib-current.txt | 1 + .../src/android/net/ConnectivityManager.java | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/common/flags.aconfig b/common/flags.aconfig index 40e6cd8767..55a96ac284 100644 --- a/common/flags.aconfig +++ b/common/flags.aconfig @@ -91,3 +91,11 @@ flag { description: "Flag for metered network firewall chain API" bug: "332628891" } + +flag { + name: "blocked_reason_oem_deny_chains" + is_exported: true + namespace: "android_core_networking" + description: "Flag for oem deny chains blocked reasons API" + bug: "328732146" +} diff --git a/framework/api/module-lib-current.txt b/framework/api/module-lib-current.txt index b2aafa0e14..d233f3e236 100644 --- a/framework/api/module-lib-current.txt +++ b/framework/api/module-lib-current.txt @@ -52,6 +52,7 @@ package android.net { field public static final int BLOCKED_REASON_LOCKDOWN_VPN = 16; // 0x10 field public static final int BLOCKED_REASON_LOW_POWER_STANDBY = 32; // 0x20 field public static final int BLOCKED_REASON_NONE = 0; // 0x0 + field @FlaggedApi("com.android.net.flags.blocked_reason_oem_deny_chains") public static final int BLOCKED_REASON_OEM_DENY = 128; // 0x80 field public static final int BLOCKED_REASON_RESTRICTED_MODE = 8; // 0x8 field @FlaggedApi("com.android.net.flags.basic_background_restrictions_enabled") public static final int FIREWALL_CHAIN_BACKGROUND = 6; // 0x6 field public static final int FIREWALL_CHAIN_DOZABLE = 1; // 0x1 diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java index 782325809c..48ed732719 100644 --- a/framework/src/android/net/ConnectivityManager.java +++ b/framework/src/android/net/ConnectivityManager.java @@ -130,6 +130,8 @@ public class ConnectivityManager { "com.android.net.flags.basic_background_restrictions_enabled"; static final String METERED_NETWORK_FIREWALL_CHAINS = "com.android.net.flags.metered_network_firewall_chains"; + static final String BLOCKED_REASON_OEM_DENY_CHAINS = + "com.android.net.flags.blocked_reason_oem_deny_chains"; } /** @@ -912,6 +914,19 @@ public class ConnectivityManager { @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int BLOCKED_REASON_APP_BACKGROUND = 1 << 6; + /** + * Flag to indicate that an app is subject to OEM-specific application restrictions that would + * result in its network access being blocked. + * + * @see #FIREWALL_CHAIN_OEM_DENY_1 + * @see #FIREWALL_CHAIN_OEM_DENY_2 + * @see #FIREWALL_CHAIN_OEM_DENY_3 + * @hide + */ + @FlaggedApi(Flags.BLOCKED_REASON_OEM_DENY_CHAINS) + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + public static final int BLOCKED_REASON_OEM_DENY = 1 << 7; + /** * Flag to indicate that an app is subject to Data saver restrictions that would * result in its metered network access being blocked. @@ -952,6 +967,7 @@ public class ConnectivityManager { BLOCKED_REASON_LOCKDOWN_VPN, BLOCKED_REASON_LOW_POWER_STANDBY, BLOCKED_REASON_APP_BACKGROUND, + BLOCKED_REASON_OEM_DENY, BLOCKED_METERED_REASON_DATA_SAVER, BLOCKED_METERED_REASON_USER_RESTRICTED, BLOCKED_METERED_REASON_ADMIN_DISABLED,