diff --git a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java index 4f2909c5ca..3befcfa43b 100644 --- a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java +++ b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java @@ -20,7 +20,6 @@ import static android.net.SocketKeepalive.ERROR_INVALID_SOCKET; import static android.net.SocketKeepalive.MIN_INTERVAL_SEC; import static android.net.SocketKeepalive.SUCCESS; import static android.net.SocketKeepalive.SUCCESS_PAUSED; -import static android.provider.DeviceConfig.NAMESPACE_TETHERING; import static android.system.OsConstants.AF_INET; import static android.system.OsConstants.AF_INET6; import static android.system.OsConstants.SOL_SOCKET; @@ -92,8 +91,8 @@ public class AutomaticOnOffKeepaliveTracker { private static final int[] ADDRESS_FAMILIES = new int[] {AF_INET6, AF_INET}; private static final long LOW_TCP_POLLING_INTERVAL_MS = 1_000L; private static final int ADJUST_TCP_POLLING_DELAY_MS = 2000; - private static final String AUTOMATIC_ON_OFF_KEEPALIVE_VERSION = - "automatic_on_off_keepalive_version"; + private static final String AUTOMATIC_ON_OFF_KEEPALIVE_DISABLE_FLAG = + "automatic_on_off_keepalive_disable_flag"; public static final long METRICS_COLLECTION_DURATION_MS = 24 * 60 * 60 * 1_000L; // ConnectivityService parses message constants from itself and AutomaticOnOffKeepaliveTracker @@ -219,8 +218,8 @@ public class AutomaticOnOffKeepaliveTracker { // Reading DeviceConfig will check if the calling uid and calling package name are the // same. Clear calling identity to align the calling uid and package final boolean enabled = BinderUtils.withCleanCallingIdentity( - () -> mDependencies.isFeatureEnabled(AUTOMATIC_ON_OFF_KEEPALIVE_VERSION, - true /* defaultEnabled */)); + () -> mDependencies.isTetheringFeatureNotChickenedOut( + AUTOMATIC_ON_OFF_KEEPALIVE_DISABLE_FLAG)); if (autoOnOff && enabled) { mAutomaticOnOffState = STATE_ENABLED; if (null == ki.mFd) { @@ -700,8 +699,8 @@ public class AutomaticOnOffKeepaliveTracker { // Clear calling identity to align the calling uid and package so that it won't fail if cts // would like to call dump() final boolean featureEnabled = BinderUtils.withCleanCallingIdentity( - () -> mDependencies.isFeatureEnabled(AUTOMATIC_ON_OFF_KEEPALIVE_VERSION, - true /* defaultEnabled */)); + () -> mDependencies.isTetheringFeatureNotChickenedOut( + AUTOMATIC_ON_OFF_KEEPALIVE_DISABLE_FLAG)); pw.println("AutomaticOnOff enabled: " + featureEnabled); pw.increaseIndent(); for (AutomaticOnOffKeepalive autoKi : mAutomaticOnOffKeepalives) { @@ -969,16 +968,13 @@ public class AutomaticOnOffKeepaliveTracker { } /** - * Find out if a feature is enabled from DeviceConfig. + * Find out if a feature is not disabled from DeviceConfig. * * @param name The name of the property to look up. - * @param defaultEnabled whether to consider the feature enabled in the absence of - * the flag. This MUST be a statically-known constant. * @return whether the feature is enabled */ - public boolean isFeatureEnabled(@NonNull final String name, final boolean defaultEnabled) { - return DeviceConfigUtils.isFeatureEnabled(mContext, NAMESPACE_TETHERING, name, - DeviceConfigUtils.TETHERING_MODULE_NAME, defaultEnabled); + public boolean isTetheringFeatureNotChickenedOut(@NonNull final String name) { + return DeviceConfigUtils.isTetheringFeatureNotChickenedOut(name); } /** diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java index 3688d832d8..708697cdd5 100755 --- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java @@ -2301,7 +2301,7 @@ public class ConnectivityServiceTest { } @Override - public boolean isFeatureEnabled(@NonNull final String name, final boolean defaultEnabled) { + public boolean isTetheringFeatureNotChickenedOut(@NonNull final String name) { // Tests for enabling the feature are verified in AutomaticOnOffKeepaliveTrackerTest. // Assuming enabled here to focus on ConnectivityService tests. return true; diff --git a/tests/unit/java/com/android/server/connectivity/AutomaticOnOffKeepaliveTrackerTest.java b/tests/unit/java/com/android/server/connectivity/AutomaticOnOffKeepaliveTrackerTest.java index b69b042667..1b71fb93bf 100644 --- a/tests/unit/java/com/android/server/connectivity/AutomaticOnOffKeepaliveTrackerTest.java +++ b/tests/unit/java/com/android/server/connectivity/AutomaticOnOffKeepaliveTrackerTest.java @@ -32,7 +32,6 @@ import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.longThat; @@ -359,7 +358,7 @@ public class AutomaticOnOffKeepaliveTrackerTest { .when(mDependencies) .newKeepaliveStatsTracker(mCtx, mTestHandler); - doReturn(true).when(mDependencies).isFeatureEnabled(any(), anyBoolean()); + doReturn(true).when(mDependencies).isTetheringFeatureNotChickenedOut(any()); doReturn(0L).when(mDependencies).getElapsedRealtime(); mAOOKeepaliveTracker = new AutomaticOnOffKeepaliveTracker(mCtx, mTestHandler, mDependencies);