From f0a3cc5a5f3646c34c6dfd58a42368dfd5807e16 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 26 Jan 2011 18:42:46 -0800 Subject: [PATCH] Handle ActivityNotFoundException in the WM policy. When invoking a registered shortcut for which the activity was not found, the startActivity throws ActivityNotFoundException. If this exception is not caught and handled, then the shortcut key is dispatched to the application instead of being suppressed as it should have been. Found while fixing Bug: 3396233 Change-Id: I0e8e9e3ba09dd403a901d5eae12839734be467ed --- .../android/internal/policy/impl/PhoneWindowManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index fd84a2a2ea481..066daa89d2674 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1402,7 +1402,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); if (shortcutIntent != null) { shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(shortcutIntent); + try { + mContext.startActivity(shortcutIntent); + } catch (ActivityNotFoundException ex) { + Slog.w(TAG, "Dropping shortcut key combination because " + + "the activity to which it is registered was not found: " + + KeyEvent.keyCodeToString(mShortcutKeyPressed) + + "+" + KeyEvent.keyCodeToString(keyCode), ex); + } } else { Slog.i(TAG, "Dropping unregistered shortcut key combination: " + KeyEvent.keyCodeToString(mShortcutKeyPressed)