diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-11-28 12:59:11 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-11-29 12:17:22 -0800 |
commit | 6651a638348c15e89e265b0a53c775cac9beafa2 (patch) | |
tree | f42e59d99363cada07cdb6f4bff69fa51bfae2ad /policy | |
parent | 500afb87a7a8b5928ef1a5196bdfd0bcc2b87e4a (diff) | |
download | frameworks_base-6651a638348c15e89e265b0a53c775cac9beafa2.zip frameworks_base-6651a638348c15e89e265b0a53c775cac9beafa2.tar.gz frameworks_base-6651a638348c15e89e265b0a53c775cac9beafa2.tar.bz2 |
Fix application launch shortcuts.
Improved quick launch bookmarks to support category-based shortcuts
instead of hardcoding package and class names for all apps.
Added a set of Intent categories for typical applications on the
platform.
Added support for some of the HID application launch usages to
reduce reliance on quick launch for special purpose keys. Some
keyboard vendors have hardcoded launch keys that synthesize
"Search + X" type key combos. The goal is to encourage them
to stop doing this by implementing more of HID.
Bug: 5674723
Change-Id: I79f1147c65a208efc3f67228c9f0fa5cd050c593
Diffstat (limited to 'policy')
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index fd9e095..aea425b 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -69,6 +69,7 @@ import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; import android.util.Slog; +import android.util.SparseArray; import android.view.Gravity; import android.view.HapticFeedbackConstants; import android.view.IWindowManager; @@ -230,7 +231,30 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Useful scan codes. private static final int SW_LID = 0x00; private static final int BTN_MOUSE = 0x110; - + + /* Table of Application Launch keys. Maps from key codes to intent categories. + * + * These are special keys that are used to launch particular kinds of applications, + * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) + * usage page. We don't support quite that many yet... + */ + static SparseArray<String> sApplicationLaunchKeyCategories; + static { + sApplicationLaunchKeyCategories = new SparseArray<String>(); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); + sApplicationLaunchKeyCategories.append( + KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); + } + /** * Lock protecting internal state. Must not call out into window * manager with lock held. (This lock will be acquired in places @@ -1649,6 +1673,23 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + // Handle application launch keys. + if (down && repeatCount == 0) { + String category = sApplicationLaunchKeyCategories.get(keyCode); + if (category != null) { + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(category); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + mContext.startActivity(intent); + } catch (ActivityNotFoundException ex) { + Slog.w(TAG, "Dropping application launch key because " + + "the activity to which it is registered was not found: " + + "keyCode=" + keyCode + ", category=" + category, ex); + } + } + } + return 0; } |