Loading src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); Loading src/com/android/settings/accessibility/AccessibilityUtil.java +11 −0 Original line number Diff line number Diff line Loading @@ -434,4 +434,15 @@ public final class AccessibilityUtil { public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) { return info.getResolveInfo().serviceInfo.applicationInfo.isSystemApp(); } /** * Bypasses the timeout restriction if volume key shortcut assigned. * * @param context the current context. */ public static void skipVolumeShortcutDialogTimeoutRestriction(Context context) { Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, /* true */ 1); } } src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -725,6 +725,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); Loading src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -367,6 +367,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends mShortcutPreference.setChecked(value != UserShortcutType.EMPTY); mShortcutPreference.setSummary( getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } } @Override Loading tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.PopupWindow; import androidx.annotation.XmlRes; Loading Loading @@ -183,6 +184,28 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE); } @Test public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() { mContext.setTheme(R.style.Theme_AppCompat); final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null); mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME; mFragment.mShortcutPreference = shortcutPreference; final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog( mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE, mFragment::callOnAlertDialogCheckboxClicked); mFragment.setupEditShortcutDialog(dialog); final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut); final CheckBox hardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox); hardwareTypeCheckBox.setChecked(true); dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick(); final boolean skipTimeoutRestriction = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0) != 0; assertThat(skipTimeoutRestriction).isTrue(); } @Test public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() { mContext.setTheme(R.style.Theme_AppCompat); Loading Loading
src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); Loading
src/com/android/settings/accessibility/AccessibilityUtil.java +11 −0 Original line number Diff line number Diff line Loading @@ -434,4 +434,15 @@ public final class AccessibilityUtil { public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) { return info.getResolveInfo().serviceInfo.applicationInfo.isSystemApp(); } /** * Bypasses the timeout restriction if volume key shortcut assigned. * * @param context the current context. */ public static void skipVolumeShortcutDialogTimeoutRestriction(Context context) { Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, /* true */ 1); } }
src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -725,6 +725,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); Loading
src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -367,6 +367,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends mShortcutPreference.setChecked(value != UserShortcutType.EMPTY); mShortcutPreference.setSummary( getShortcutTypeSummary(getPrefContext())); if (mHardwareTypeCheckBox.isChecked()) { AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); } } @Override Loading
tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.PopupWindow; import androidx.annotation.XmlRes; Loading Loading @@ -183,6 +184,28 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE); } @Test public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() { mContext.setTheme(R.style.Theme_AppCompat); final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null); mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME; mFragment.mShortcutPreference = shortcutPreference; final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog( mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE, mFragment::callOnAlertDialogCheckboxClicked); mFragment.setupEditShortcutDialog(dialog); final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut); final CheckBox hardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox); hardwareTypeCheckBox.setChecked(true); dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick(); final boolean skipTimeoutRestriction = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0) != 0; assertThat(skipTimeoutRestriction).isTrue(); } @Test public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() { mContext.setTheme(R.style.Theme_AppCompat); Loading