Remove legacy flag for time feedback
This change removes the server flag for `time_help_and_feedback_feature_supported` as public ramps are generally discouraged in Android now. See go/android-legacy-flags. The trunk stable flag still exists, so this feature is still flagged properly. This change also include minor refactor to simplify logic around flags now that the server flag is no longer needed. Flag: EXEMPT removing time_help_and_feedback_feature_supported Bug: 283239837 Change-Id: Ic5058a81186d63df4a2e57eaab4d1c120d0806bc
This commit is contained in:
@@ -24,45 +24,51 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TimeFeedbackPreferenceCategoryControllerTest {
|
||||
|
||||
private TestTimeFeedbackPreferenceCategoryController mController;
|
||||
private TimeFeedbackPreferenceCategoryController mController;
|
||||
@Mock private AbstractPreferenceController mChildController;
|
||||
|
||||
@Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Context context = RuntimeEnvironment.getApplication();
|
||||
|
||||
mController = new TestTimeFeedbackPreferenceCategoryController(context, "test_key");
|
||||
mController = new TimeFeedbackPreferenceCategoryController(context, "test_key");
|
||||
mController.addChildController(mChildController);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void getAvailabilityStatus_featureEnabledPrimary() {
|
||||
mController.setTimeFeedbackFeatureEnabled(false);
|
||||
|
||||
when(mChildController.isAvailable()).thenReturn(true);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void getAvailabilityStatus_childControllerSecondary() {
|
||||
mController.setTimeFeedbackFeatureEnabled(true);
|
||||
|
||||
when(mChildController.isAvailable()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
@@ -71,27 +77,4 @@ public class TimeFeedbackPreferenceCategoryControllerTest {
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend class under test to change {@link #isTimeFeedbackFeatureEnabled} to not call
|
||||
* {@link DateTimeLaunchUtils} because that's non-trivial to fake.
|
||||
*/
|
||||
private static class TestTimeFeedbackPreferenceCategoryController
|
||||
extends TimeFeedbackPreferenceCategoryController {
|
||||
|
||||
private boolean mTimeFeedbackFeatureEnabled;
|
||||
|
||||
TestTimeFeedbackPreferenceCategoryController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
void setTimeFeedbackFeatureEnabled(boolean value) {
|
||||
this.mTimeFeedbackFeatureEnabled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTimeFeedbackFeatureEnabled() {
|
||||
return mTimeFeedbackFeatureEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import static android.provider.DeviceConfig.NAMESPACE_SYSTEM_TIME;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
@@ -38,9 +36,9 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.DeviceConfig;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -82,6 +80,7 @@ public class TimeFeedbackPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void emptyIntentUri_controllerNotAvailable() {
|
||||
String emptyIntentUri = "";
|
||||
TimeFeedbackPreferenceController controller =
|
||||
@@ -90,11 +89,18 @@ public class TimeFeedbackPreferenceControllerTest {
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void datetimeFeedbackDisabled_controllerNotAvailable() {
|
||||
TimeFeedbackPreferenceController controller =
|
||||
new TimeFeedbackPreferenceController(
|
||||
mContext, mContext.getPackageManager(), "test_key", TEST_INTENT_URI);
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void validIntentUri_targetHandlerNotFound_returnsConditionallyUnavailable() {
|
||||
DeviceConfig.setProperty(NAMESPACE_SYSTEM_TIME,
|
||||
DateTimeLaunchUtils.KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, "true", true);
|
||||
when(mMockPackageManager.resolveActivity(any(), anyInt())).thenReturn(null);
|
||||
|
||||
TimeFeedbackPreferenceController controller =
|
||||
@@ -107,8 +113,6 @@ public class TimeFeedbackPreferenceControllerTest {
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void validIntentUri_targetHandlerAvailable_returnsAvailable() {
|
||||
DeviceConfig.setProperty(NAMESPACE_SYSTEM_TIME,
|
||||
DateTimeLaunchUtils.KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, "true", true);
|
||||
when(mMockPackageManager.resolveActivity(any(), anyInt())).thenReturn(
|
||||
createDummyResolveInfo());
|
||||
|
||||
@@ -120,6 +124,7 @@ public class TimeFeedbackPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_DATETIME_FEEDBACK})
|
||||
public void clickPreference() {
|
||||
Preference preference = new Preference(mContext);
|
||||
|
||||
|
Reference in New Issue
Block a user