Merge "Revert "Add method to read trunk stable flag"" into main

This commit is contained in:
Motomu Utsumi 2024-02-08 10:37:09 +00:00 • committed by Gerrit Code Review
commit 6de59fa208
2 changed files with 0 additions and 55 deletions

View file

@ -64,9 +64,6 @@ public final class DeviceConfigUtils {
@VisibleForTesting
public static final long DEFAULT_PACKAGE_VERSION = 1000;
private static final String CORE_NETWORKING_TRUNK_STABLE_NAMESPACE = "android_core_networking";
private static final String CORE_NETWORKING_TRUNK_STABLE_FLAG_PACKAGE = "com.android.net.flags";
@VisibleForTesting
public static void resetPackageVersionCacheForTest() {
sPackageVersion = -1;
@ -409,31 +406,4 @@ public final class DeviceConfigUtils {
return pkgs.get(0).activityInfo.applicationInfo.packageName;
}
/**
* Check whether one specific trunk stable flag in android_core_networking namespace is enabled.
* This method reads trunk stable feature flag value from DeviceConfig directly since
* java_aconfig_library soong module is not available in the mainline branch.
* After the mainline branch support the aconfig soong module, this function must be removed and
* java_aconfig_library must be used instead to check if the feature is enabled.
*
* @param flagName The name of the trunk stable flag
* @return true if this feature is enabled, or false if disabled.
*/
public static boolean isTrunkStableFeatureEnabled(final String flagName) {
return isTrunkStableFeatureEnabled(
CORE_NETWORKING_TRUNK_STABLE_NAMESPACE,
CORE_NETWORKING_TRUNK_STABLE_FLAG_PACKAGE,
flagName
);
}
private static boolean isTrunkStableFeatureEnabled(final String namespace,
final String packageName, final String flagName) {
return DeviceConfig.getBoolean(
namespace,
packageName + "." + flagName,
false /* defaultValue */
);
}
}

View file

@ -71,10 +71,6 @@ import java.util.Arrays;
public class DeviceConfigUtilsTest {
private static final String TEST_NAME_SPACE = "connectivity";
private static final String TEST_EXPERIMENT_FLAG = "experiment_flag";
private static final String CORE_NETWORKING_TRUNK_STABLE_NAMESPACE = "android_core_networking";
private static final String TEST_TRUNK_STABLE_FLAG = "trunk_stable_feature";
private static final String TEST_CORE_NETWORKING_TRUNK_STABLE_FLAG_PROPERTY =
"com.android.net.flags.trunk_stable_feature";
private static final int TEST_FLAG_VALUE = 28;
private static final String TEST_FLAG_VALUE_STRING = "28";
private static final int TEST_DEFAULT_FLAG_VALUE = 0;
@ -507,25 +503,4 @@ public class DeviceConfigUtilsTest {
verify(mContext, never()).getPackageName();
verify(mPm, never()).getPackageInfo(anyString(), anyInt());
}
@Test
public void testIsCoreNetworkingTrunkStableFeatureEnabled() {
doReturn(null).when(() -> DeviceConfig.getProperty(
CORE_NETWORKING_TRUNK_STABLE_NAMESPACE,
TEST_CORE_NETWORKING_TRUNK_STABLE_FLAG_PROPERTY));
assertFalse(DeviceConfigUtils.isTrunkStableFeatureEnabled(
TEST_TRUNK_STABLE_FLAG));
doReturn("false").when(() -> DeviceConfig.getProperty(
CORE_NETWORKING_TRUNK_STABLE_NAMESPACE,
TEST_CORE_NETWORKING_TRUNK_STABLE_FLAG_PROPERTY));
assertFalse(DeviceConfigUtils.isTrunkStableFeatureEnabled(
TEST_TRUNK_STABLE_FLAG));
doReturn("true").when(() -> DeviceConfig.getProperty(
CORE_NETWORKING_TRUNK_STABLE_NAMESPACE,
TEST_CORE_NETWORKING_TRUNK_STABLE_FLAG_PROPERTY));
assertTrue(DeviceConfigUtils.isTrunkStableFeatureEnabled(
TEST_TRUNK_STABLE_FLAG));
}
}