Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1eedde0d authored by Peter_Liang's avatar Peter_Liang
Browse files

Shouldn't turn on other accessibility features in SuW.

Root Cause:
During the SuW, user could turn on other accessibility features except for Magnification, Select to Speak, and Talkback through edit shortcut menu list.

Solution:
Hide the edit shortcuts button if in the SuW period to avoid to turn on others.

Bug: 158046037
Test: manual test
Change-Id: I06e5fde2320c0736ecaf9feb912349c5965cb491
parent 0eadc171
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.Shortc
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.createEnableDialogContentView;
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getInstalledTargets;
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getTargets;
import static com.android.internal.accessibility.util.AccessibilityUtils.isUserSetupCompleted;

import android.annotation.Nullable;
import android.app.Activity;
@@ -61,18 +62,8 @@ public class AccessibilityShortcutChooserActivity extends Activity {
        }

        mTargets.addAll(getTargets(this, mShortcutType));

        final String selectDialogTitle =
                getString(R.string.accessibility_select_shortcut_menu_title);
        mTargetAdapter = new ShortcutTargetAdapter(mTargets);
        mMenuDialog = new AlertDialog.Builder(this)
                .setTitle(selectDialogTitle)
                .setAdapter(mTargetAdapter, /* listener= */ null)
                .setPositiveButton(
                        getString(R.string.edit_accessibility_shortcut_menu_button),
                        /* listener= */ null)
                .setOnDismissListener(dialog -> finish())
                .create();
        mMenuDialog = createMenuDialog();
        mMenuDialog.setOnShowListener(dialog -> updateDialogListeners());
        mMenuDialog.show();
    }
@@ -154,4 +145,22 @@ public class AccessibilityShortcutChooserActivity extends Activity {
        mMenuDialog.getListView().setOnItemClickListener(
                isEditMenuMode ? this::onTargetChecked : this::onTargetSelected);
    }

    private AlertDialog createMenuDialog() {
        final String dialogTitle =
                getString(R.string.accessibility_select_shortcut_menu_title);

        final AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .setTitle(dialogTitle)
                .setAdapter(mTargetAdapter, /* listener= */ null)
                .setOnDismissListener(dialog -> finish());

        if (isUserSetupCompleted(this)) {
            final String positiveButtonText =
                    getString(R.string.edit_accessibility_shortcut_menu_button);
            builder.setPositiveButton(positiveButtonText, /* listener= */ null);
        }

        return builder.create();
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -156,4 +156,16 @@ public final class AccessibilityUtils {

        return false;
    }

    /**
     * Indicates whether the current user has completed setup via the setup wizard.
     * {@link android.provider.Settings.Secure#USER_SETUP_COMPLETE}
     *
     * @return {@code true} if the setup is completed.
     */
    public static boolean isUserSetupCompleted(Context context) {
        return Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.USER_SETUP_COMPLETE, /* def= */ 0, UserHandle.USER_CURRENT)
                != /* false */ 0;
    }
}