From 2359e7b554652f1be84242682953716bfcadc619 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Wed, 13 Sep 2023 17:32:07 +0900 Subject: [PATCH] Remove defaultEnabled arg from isNetworkStackFeatureEnabled Test: NetworkStaticLibsTests Bug: 279108992 Change-Id: Id5409158fd720efc92e1b39678e636a8a7d5a0a5 --- .../net/module/util/DeviceConfigUtils.java | 26 +++++-------------- .../module/util/DeviceConfigUtilsTest.java | 7 ++--- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java b/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java index 5b75699774..5b7cbb855b 100644 --- a/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java +++ b/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java @@ -165,32 +165,18 @@ public final class DeviceConfigUtils { * * This is useful to ensure that if a module install is rolled back, flags are not left fully * rolled out on a version where they have not been well tested. + * + * If the feature is disabled by default and enabled by flag push, this method should be used. + * If the feature is enabled by default and disabled by flag push (kill switch), + * {@link #isNetworkStackFeatureNotChickenedOut(Context, String)} should be used. + * * @param context The global context information about an app environment. * @param name The name of the property to look up. * @return true if this feature is enabled, or false if disabled. */ public static boolean isNetworkStackFeatureEnabled(@NonNull Context context, @NonNull String name) { - return isNetworkStackFeatureEnabled(context, name, false /* defaultEnabled */); - } - - /** - * Check whether or not one specific experimental feature for a particular namespace from - * {@link DeviceConfig} is enabled by comparing module package version - * with current version of property. If this property version is valid, the corresponding - * experimental feature would be enabled, otherwise disabled. - * - * This is useful to ensure that if a module install is rolled back, flags are not left fully - * rolled out on a version where they have not been well tested. - * @param context The global context information about an app environment. - * @param name The name of the property to look up. - * @param defaultEnabled The value to return if the property does not exist or its value is - * null. - * @return true if this feature is enabled, or false if disabled. - */ - public static boolean isNetworkStackFeatureEnabled(@NonNull Context context, - @NonNull String name, boolean defaultEnabled) { - return isFeatureEnabled(NAMESPACE_CONNECTIVITY, name, defaultEnabled, + return isFeatureEnabled(NAMESPACE_CONNECTIVITY, name, false /* defaultEnabled */, () -> getPackageVersion(context)); } diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/DeviceConfigUtilsTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/DeviceConfigUtilsTest.java index 9e046765e2..f32337dc1f 100644 --- a/staticlibs/tests/unit/src/com/android/net/module/util/DeviceConfigUtilsTest.java +++ b/staticlibs/tests/unit/src/com/android/net/module/util/DeviceConfigUtilsTest.java @@ -301,15 +301,12 @@ public class DeviceConfigUtilsTest { assertFalse(DeviceConfigUtils.isNetworkStackFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG)); assertFalse(DeviceConfigUtils.isTetheringFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG)); - // Follow defaultEnabled if the flag is not set + // If the flag is not set feature is disabled doReturn(null).when(() -> DeviceConfig.getProperty(NAMESPACE_CONNECTIVITY, TEST_EXPERIMENT_FLAG)); doReturn(null).when(() -> DeviceConfig.getProperty(NAMESPACE_TETHERING, TEST_EXPERIMENT_FLAG)); - assertFalse(DeviceConfigUtils.isNetworkStackFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG, - false /* defaultEnabled */)); - assertTrue(DeviceConfigUtils.isNetworkStackFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG, - true /* defaultEnabled */)); + assertFalse(DeviceConfigUtils.isNetworkStackFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG)); assertFalse(DeviceConfigUtils.isTetheringFeatureEnabled(mContext, TEST_EXPERIMENT_FLAG)); }