From a3d2693e05cb80292986249b3eb09f405d99552d Mon Sep 17 00:00:00 2001 From: Andrei Stingaceanu Date: Fri, 15 Jul 2016 11:12:20 +0100 Subject: [PATCH] Keyboard shortcuts: minor Activity broadcast refactor Since the broadcast intents have an action, specifying an explicit component name is not needed. Specified only the package name and left it for the system to resolve the full component name for the receiver that handles the action in that package. Also got rid of warning: "Calling a method in the system process without a qualified user" by correctly sending the broadcast as the SYSTEM user. Bug: 28012198 Change-Id: Ia572fb1b7f2f3c96160d16e2842d6aff3b7f10a1 --- core/java/android/app/Activity.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 0c0af87ca3ae8..edeb8389a2b1d 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -724,8 +724,6 @@ public class Activity extends ContextThemeWrapper private static final String REQUEST_PERMISSIONS_WHO_PREFIX = "@android:requestPermissions:"; private static final String KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME = "com.android.systemui"; - private static final String KEYBOARD_SHORTCUTS_RECEIVER_CLASS_NAME = - "com.android.systemui.statusbar.KeyboardShortcutsReceiver"; private static class ManagedDialog { Dialog mDialog; @@ -1694,9 +1692,8 @@ public class Activity extends ContextThemeWrapper */ public final void requestShowKeyboardShortcuts() { Intent intent = new Intent(Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS); - intent.setComponent(new ComponentName(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME, - KEYBOARD_SHORTCUTS_RECEIVER_CLASS_NAME)); - sendBroadcast(intent); + intent.setPackage(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME); + sendBroadcastAsUser(intent, UserHandle.SYSTEM); } /** @@ -1704,9 +1701,8 @@ public class Activity extends ContextThemeWrapper */ public final void dismissKeyboardShortcutsHelper() { Intent intent = new Intent(Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS); - intent.setComponent(new ComponentName(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME, - KEYBOARD_SHORTCUTS_RECEIVER_CLASS_NAME)); - sendBroadcast(intent); + intent.setPackage(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME); + sendBroadcastAsUser(intent, UserHandle.SYSTEM); } @Override