1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 08:36:19 +00:00
treble_evolution/patches/platform_packages_modules_Connectivity/0013-Remove-sdk-level-check-when-calling-getDataSaverEnab.patch
2024-04-24 15:13:17 +00:00

63 lines
2.5 KiB
Diff

From 2ecd01500d51fff45c3b74852f1841f7a6d49d75 Mon Sep 17 00:00:00 2001
From: Junyu Lai <junyulai@google.com>
Date: Mon, 18 Dec 2023 16:13:12 +0800
Subject: [PATCH 13/13] Remove sdk level check when calling getDataSaverEnabled
Follow-up from aosp/2856948, the data saver status value is
filled by ConnectivityService before Android V. Thus, calling
BpfNetMapsReader#getDataSaverEnabled() is a legit use case, which
should not trigger log.wtf.
Remove the check accordingly.
Test: TH
Bug: 314858283
Fix: 316839561
Change-Id: I90c85ab98fbefd1f99ec799a4eec8d1d0cfd47b0
---
framework/src/android/net/BpfNetMapsReader.java | 8 --------
tests/unit/java/android/net/BpfNetMapsReaderTest.kt | 1 -
2 files changed, 9 deletions(-)
diff --git a/framework/src/android/net/BpfNetMapsReader.java b/framework/src/android/net/BpfNetMapsReader.java
index 4ab6d3e0b6..ee422abd9c 100644
--- a/framework/src/android/net/BpfNetMapsReader.java
+++ b/framework/src/android/net/BpfNetMapsReader.java
@@ -36,7 +36,6 @@ import android.os.Build;
import android.os.ServiceSpecificException;
import android.system.ErrnoException;
import android.system.Os;
-import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.modules.utils.build.SdkLevel;
@@ -278,13 +277,6 @@ public class BpfNetMapsReader {
public boolean getDataSaverEnabled() {
throwIfPreT("getDataSaverEnabled is not available on pre-T devices");
- // Note that this is not expected to be called until V given that it relies on the
- // counterpart platform solution to set data saver status to bpf.
- // See {@code NetworkManagementService#setDataSaverModeEnabled}.
- if (!SdkLevel.isAtLeastV()) {
- Log.wtf(TAG, "getDataSaverEnabled is not expected to be called on pre-V devices");
- }
-
try {
return mDataSaverEnabledMap.getValue(DATA_SAVER_ENABLED_KEY).val == DATA_SAVER_ENABLED;
} catch (ErrnoException e) {
diff --git a/tests/unit/java/android/net/BpfNetMapsReaderTest.kt b/tests/unit/java/android/net/BpfNetMapsReaderTest.kt
index 9de7f4dc7c..8919666551 100644
--- a/tests/unit/java/android/net/BpfNetMapsReaderTest.kt
+++ b/tests/unit/java/android/net/BpfNetMapsReaderTest.kt
@@ -213,7 +213,6 @@ class BpfNetMapsReaderTest {
assertFalse(isUidNetworkingBlocked(TEST_UID3))
}
- @IgnoreUpTo(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Test
fun testGetDataSaverEnabled() {
testDataSaverEnabledMap.updateEntry(DATA_SAVER_ENABLED_KEY, U8(DATA_SAVER_DISABLED))
--
2.25.1