Merge "Disable "double tap to check" when "always on""

This commit is contained in:
TreeHugger Robot
2018-02-13 04:07:14 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 1 deletions

View File

@@ -79,7 +79,7 @@ public class AmbientDisplaySettings extends DashboardFragment {
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
return buildPreferenceControllers(context, getLifecycle(), return buildPreferenceControllers(context, getLifecycle(),
new AmbientDisplayConfiguration(context), mMetricsFeatureProvider, new AmbientDisplayConfiguration(context), mMetricsFeatureProvider,
() -> { updatePreferenceStates(); }); this::updatePreferenceStates);
} }
@Override @Override

View File

@@ -102,4 +102,9 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE, return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
ON /* onValue */, intent, isAvailable(), ON /* defaultValue */); ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
} }
@Override
protected boolean canHandleClicks() {
return !mAmbientConfig.alwaysOnEnabled(mUserId);
}
} }

View File

@@ -161,4 +161,16 @@ public class DoubleTapScreenPreferenceControllerTest {
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete( assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
mAmbientDisplayConfiguration, prefs)).isTrue(); mAmbientDisplayConfiguration, prefs)).isTrue();
} }
@Test
public void canHandleClicks_falseWhenAlwaysOnEnabled() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
assertThat(mController.canHandleClicks()).isFalse();
}
@Test
public void canHandleClicks_trueWhenAlwaysOnDisabled() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
assertThat(mController.canHandleClicks()).isTrue();
}
} }