From 315ae1ebc1a6e2a7c73353a5ed19fc3f26d4d422 Mon Sep 17 00:00:00 2001 From: David Su Date: Fri, 25 Sep 2020 14:42:18 -0700 Subject: [PATCH] SdkLevelUtil: remove isAtLeastSMockable() The mockable version can only be used where object construction is controlled e.g. in Wifi service. For existing public APIs, SdkLevelUtil cannot be injected because the constructor can't be changed. Thus, the strategy for testing this is: 1. Gate the unit tests with the same SDK level requirements, and test on a real device with that SDK version, or 2. Use static mocking. In either case, the mockable version is not useful. Bug: 169443762 Test: atest FrameworksWifiApiTests Change-Id: Icf2f32b3a40512f87bf32d1d80622c22e4454406 --- wifi/java/android/net/wifi/util/SdkLevelUtil.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wifi/java/android/net/wifi/util/SdkLevelUtil.java b/wifi/java/android/net/wifi/util/SdkLevelUtil.java index 042634c7125cd..d08d4fd742b74 100644 --- a/wifi/java/android/net/wifi/util/SdkLevelUtil.java +++ b/wifi/java/android/net/wifi/util/SdkLevelUtil.java @@ -23,17 +23,17 @@ import android.os.Build; * * This can be used to disable new Wifi APIs added in Mainline updates on older SDK versions. * + * Note: if certain functionality is gated with SdkLevelUtil, its corresponding unit tests should + * also be gated by the same condition. Then, those unit tests will only be exercised on a base + * system image satisfying that condition. + * Alternatively, it can be tested via static mocking. + * * @hide */ public class SdkLevelUtil { - /** This class is instantiable to allow easy mocking. */ - public SdkLevelUtil() { } - - /** See {@link #isAtLeastS()}. This version is non-static to allow easy mocking. */ - public boolean isAtLeastSMockable() { - return isAtLeastS(); - } + /** This class is not instantiable. */ + private SdkLevelUtil() {} /** Returns true if the Android platform SDK is at least "S", false otherwise. */ public static boolean isAtLeastS() {