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

Commit 91341b56 authored by Ben Murdoch's avatar Ben Murdoch Committed by Android Build Coastguard Worker
Browse files

RESTRICT AUTOMERGE Clear app-provided shortcut icons

When displaying keyboard shortcuts provided by an app, clear
any icon that may have been set (this is only possible via
reflection, and is not a intended for usage outside of the system).

Bug: 331180422
Test: Verify on device
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d02d24723e150315c416e5f02953cd50ae40cfdf)
Merged-In: If7e291eb2254c3cbec23673c65e7477e6ad45b09
Change-Id: If7e291eb2254c3cbec23673c65e7477e6ad45b09
parent 1e40e7e5
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.os.Parcelable;
 */
public final class KeyboardShortcutInfo implements Parcelable {
    private final CharSequence mLabel;
    private final Icon mIcon;
    private Icon mIcon;
    private final char mBaseCharacter;
    private final int mKeycode;
    private final int mModifiers;
@@ -115,6 +115,15 @@ public final class KeyboardShortcutInfo implements Parcelable {
        return mIcon;
    }

    /**
     * Removes an icon that was previously set.
     *
     * @hide
     */
    public void clearIcon() {
        mIcon = null;
    }

    /**
     * Returns the base keycode that, combined with the modifiers, triggers this shortcut. If the
     * base character was set instead, returns {@link KeyEvent#KEYCODE_UNKNOWN}. Valid keycodes are
+9 −0
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ public final class KeyboardShortcuts {
            @Override
            public void onKeyboardShortcutsReceived(
                    final List<KeyboardShortcutGroup> result) {
                sanitiseShortcuts(result);
                result.add(getSystemShortcuts());
                final KeyboardShortcutGroup appShortcuts = getDefaultApplicationShortcuts();
                if (appShortcuts != null) {
@@ -388,6 +389,14 @@ public final class KeyboardShortcuts {
        }, deviceId);
    }

    static void sanitiseShortcuts(List<KeyboardShortcutGroup> shortcutGroups) {
        for (KeyboardShortcutGroup group : shortcutGroups) {
            for (KeyboardShortcutInfo info : group.getItems()) {
                info.clearIcon();
            }
        }
    }

    private void dismissKeyboardShortcuts() {
        if (mKeyboardShortcutsDialog != null) {
            mKeyboardShortcutsDialog.dismiss();