Prevent play/pause key from starting voice search on TV
CDD enforces the TV devices' remote controllers to have search button,
so long-press of play/pause key to start voice search doesn't make
sense.
Test: Manual, and run CTS (MediaSessionTest)
Bug: 63139504
Change-Id: I757ad4a9f1d9677cefc6403a96c5bf6c7323b575
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index a0487f9..b77ed91 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -108,6 +108,7 @@
private ContentResolver mContentResolver;
private SettingsObserver mSettingsObserver;
private INotificationManager mNotificationManager;
+ private boolean mHasFeatureLeanback;
// The FullUserRecord of the current users. (i.e. The foreground user that isn't a profile)
// It's always not null after the MediaSessionService is started.
@@ -154,6 +155,8 @@
mContentResolver = getContext().getContentResolver();
mSettingsObserver = new SettingsObserver();
mSettingsObserver.observe();
+ mHasFeatureLeanback = getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_LEANBACK);
updateUser();
}
@@ -1509,7 +1512,7 @@
private boolean isVoiceKey(int keyCode) {
return keyCode == KeyEvent.KEYCODE_HEADSETHOOK
- || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE;
+ || (!mHasFeatureLeanback && keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
}
private boolean isUserSetupComplete() {