Merge "a11y: Only show the cursor following mode setting with detected mouse" into main
This commit is contained in:
@@ -213,8 +213,8 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isMagnificationCursorFollowingModeDialogSupported() {
|
private static boolean isMagnificationCursorFollowingModeDialogSupported() {
|
||||||
// TODO(b/398066000): Hide the setting when no pointer device exists for most form factors.
|
return com.android.settings.accessibility.Flags.enableMagnificationCursorFollowingDialog()
|
||||||
return com.android.settings.accessibility.Flags.enableMagnificationCursorFollowingDialog();
|
&& hasMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -679,6 +679,21 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
getPrefContext(), MAGNIFICATION_CONTROLLER_NAME);
|
getPrefContext(), MAGNIFICATION_CONTROLLER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a mouse is attached.
|
||||||
|
*/
|
||||||
|
private static boolean hasMouse() {
|
||||||
|
final int[] devices = InputDevice.getDeviceIds();
|
||||||
|
for (int i = 0; i < devices.length; i++) {
|
||||||
|
InputDevice device = InputDevice.getDevice(devices[i]);
|
||||||
|
if (device != null && (device.getSources() & InputDevice.SOURCE_MOUSE)
|
||||||
|
== InputDevice.SOURCE_MOUSE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasHardKeyboard() {
|
private boolean hasHardKeyboard() {
|
||||||
final int[] devices = InputDevice.getDeviceIds();
|
final int[] devices = InputDevice.getDeviceIds();
|
||||||
for (int i = 0; i < devices.length; i++) {
|
for (int i = 0; i < devices.length; i++) {
|
||||||
|
@@ -546,6 +546,45 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
assertThat(switchPreference).isNull();
|
assertThat(switchPreference).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(com.android.settings.accessibility.Flags
|
||||||
|
.FLAG_ENABLE_MAGNIFICATION_CURSOR_FOLLOWING_DIALOG)
|
||||||
|
@Config(shadows = ShadowInputDevice.class)
|
||||||
|
public void onCreateView_cursorFollowingModeDisabled_settingsPreferenceIsNull() {
|
||||||
|
addMouseDevice();
|
||||||
|
|
||||||
|
mFragController.create(R.id.main_content, /* bundle= */null).start().resume().get();
|
||||||
|
|
||||||
|
final Preference preference = mFragController.get().findPreference(
|
||||||
|
MagnificationCursorFollowingModePreferenceController.PREF_KEY);
|
||||||
|
assertThat(preference).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(com.android.settings.accessibility.Flags
|
||||||
|
.FLAG_ENABLE_MAGNIFICATION_CURSOR_FOLLOWING_DIALOG)
|
||||||
|
public void onCreateView_cursorFollowingModeEnabled_settingsPreferenceIsNullWithoutMouse() {
|
||||||
|
mFragController.create(R.id.main_content, /* bundle= */null).start().resume().get();
|
||||||
|
|
||||||
|
final Preference preference = mFragController.get().findPreference(
|
||||||
|
MagnificationCursorFollowingModePreferenceController.PREF_KEY);
|
||||||
|
assertThat(preference).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(com.android.settings.accessibility.Flags
|
||||||
|
.FLAG_ENABLE_MAGNIFICATION_CURSOR_FOLLOWING_DIALOG)
|
||||||
|
@Config(shadows = ShadowInputDevice.class)
|
||||||
|
public void onCreateView_cursorFollowingModeEnabled_settingsPreferenceIsNotNullWithMouse() {
|
||||||
|
addMouseDevice();
|
||||||
|
|
||||||
|
mFragController.create(R.id.main_content, /* bundle= */null).start().resume().get();
|
||||||
|
|
||||||
|
final Preference preference = mFragController.get().findPreference(
|
||||||
|
MagnificationCursorFollowingModePreferenceController.PREF_KEY);
|
||||||
|
assertThat(preference).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
|
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
|
||||||
Correspondence instanceOf = Correspondence.transforming(
|
Correspondence instanceOf = Correspondence.transforming(
|
||||||
@@ -903,11 +942,13 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
Flags.FLAG_ENABLE_LOW_VISION_HATS,
|
Flags.FLAG_ENABLE_LOW_VISION_HATS,
|
||||||
com.android.settings.accessibility.Flags
|
com.android.settings.accessibility.Flags
|
||||||
.FLAG_ENABLE_MAGNIFICATION_CURSOR_FOLLOWING_DIALOG})
|
.FLAG_ENABLE_MAGNIFICATION_CURSOR_FOLLOWING_DIALOG})
|
||||||
|
@Config(shadows = ShadowInputDevice.class)
|
||||||
public void getNonIndexableKeys_hasShortcutAndAllFeaturesEnabled_allItemsSearchable() {
|
public void getNonIndexableKeys_hasShortcutAndAllFeaturesEnabled_allItemsSearchable() {
|
||||||
mShadowAccessibilityManager.setAccessibilityShortcutTargets(
|
mShadowAccessibilityManager.setAccessibilityShortcutTargets(
|
||||||
TRIPLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
|
TRIPLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
|
||||||
setAlwaysOnSupported(true);
|
setAlwaysOnSupported(true);
|
||||||
setJoystickSupported(true);
|
setJoystickSupported(true);
|
||||||
|
addMouseDevice();
|
||||||
|
|
||||||
final List<String> niks = ToggleScreenMagnificationPreferenceFragment
|
final List<String> niks = ToggleScreenMagnificationPreferenceFragment
|
||||||
.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||||
@@ -1026,6 +1067,14 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
enabled ? ON : OFF);
|
enabled ? ON : OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addMouseDevice() {
|
||||||
|
int deviceId = 1;
|
||||||
|
ShadowInputDevice.sDeviceIds = new int[]{deviceId};
|
||||||
|
InputDevice device = ShadowInputDevice.makeInputDevicebyIdWithSources(deviceId,
|
||||||
|
InputDevice.SOURCE_MOUSE);
|
||||||
|
ShadowInputDevice.addDevice(deviceId, device);
|
||||||
|
}
|
||||||
|
|
||||||
private String getStringFromSettings(String key) {
|
private String getStringFromSettings(String key) {
|
||||||
return Settings.Secure.getString(mContext.getContentResolver(), key);
|
return Settings.Secure.getString(mContext.getContentResolver(), key);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user