DivestOS/Patches/LineageOS-16.0/android_frameworks_base/408510.patch
Tavi ce2a2ee149
Fixup + Churn
Signed-off-by: Tavi <tavi@divested.dev>
2024-11-14 10:09:26 -05:00

83 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Murdoch <benm@google.com>
Date: Fri, 30 Aug 2024 17:22:59 +0000
Subject: [PATCH] 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:a031e9f221cf87657c42d3ed0ddbe93fc6d7a9c3)
Merged-In: If7e291eb2254c3cbec23673c65e7477e6ad45b09
Change-Id: If7e291eb2254c3cbec23673c65e7477e6ad45b09
---
core/java/android/view/KeyboardShortcutInfo.java | 13 +++++++++++--
.../systemui/statusbar/KeyboardShortcuts.java | 9 +++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/core/java/android/view/KeyboardShortcutInfo.java b/core/java/android/view/KeyboardShortcutInfo.java
index c934a4e31f98..136c19f3f11e 100644
--- a/core/java/android/view/KeyboardShortcutInfo.java
+++ b/core/java/android/view/KeyboardShortcutInfo.java
@@ -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
@@ -165,4 +174,4 @@ public final class KeyboardShortcutInfo implements Parcelable {
return new KeyboardShortcutInfo[size];
}
};
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
index 2d16d2209c9e..5779aec21683 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
@@ -376,6 +376,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) {
@@ -386,6 +387,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();