summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-05-20 14:53:39 -0700
committerRoboErik <epastern@google.com>2014-05-20 14:57:46 -0700
commit9a9d0b5f6f4be758ed6c8b837a9dd01a451bc0c0 (patch)
tree5bf1b7009e161cb10b2a88c76c5848814dcaf276 /policy
parent418c10ca9df1505509afeffd558cd92fc97bc635 (diff)
downloadframeworks_base-9a9d0b5f6f4be758ed6c8b837a9dd01a451bc0c0.zip
frameworks_base-9a9d0b5f6f4be758ed6c8b837a9dd01a451bc0c0.tar.gz
frameworks_base-9a9d0b5f6f4be758ed6c8b837a9dd01a451bc0c0.tar.bz2
Handle headsethook voice launching
This launches voice search when headsethook is long pressed unless you're in a call. The handling is done in MediaSessionService. This CL also adds a switch to the new APIs to the fallback event handler which was missed previously. Change-Id: I1cbdff1d6e9f5293885dd8aaed8ba13cb15b36d4
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
index 417527c..b2ecb61 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.IAudioService;
+import android.media.session.MediaSessionLegacyHelper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -39,6 +40,9 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
private static String TAG = "PhoneFallbackEventHandler";
private static final boolean DEBUG = false;
+ // Use the new sessions APIs
+ private static final boolean USE_SESSIONS = true;
+
Context mContext;
View mView;
@@ -70,14 +74,14 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
return onKeyUp(keyCode, event);
}
}
-
+
boolean onKeyDown(int keyCode, KeyEvent event) {
/* ****************************************************************************
* HOW TO DECIDE WHERE YOUR KEY HANDLING GOES.
* See the comment in PhoneWindow.onKeyDown
* ****************************************************************************/
final KeyEvent.DispatcherState dispatcher = mView.getKeyDispatcherState();
-
+
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
@@ -156,7 +160,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
if (event.getRepeatCount() == 0) {
dispatcher.startTracking(event, this);
} else if (event.isLongPress() && dispatcher.isTracking(event)) {
- Configuration config = mContext.getResources().getConfiguration();
+ Configuration config = mContext.getResources().getConfiguration();
if (config.keyboard == Configuration.KEYBOARD_NOKEYS
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
// launch the search activity
@@ -191,7 +195,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
if (dispatcher != null) {
dispatcher.handleUpEvent(event);
}
-
+
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
@@ -277,29 +281,33 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
}
return mKeyguardManager;
}
-
+
AudioManager getAudioManager() {
if (mAudioManager == null) {
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
return mAudioManager;
}
-
+
void sendCloseSystemWindows() {
PhoneWindowManager.sendCloseSystemWindows(mContext, null);
}
private void handleMediaKeyEvent(KeyEvent keyEvent) {
- IAudioService audioService = IAudioService.Stub.asInterface(
- ServiceManager.checkService(Context.AUDIO_SERVICE));
- if (audioService != null) {
- try {
- audioService.dispatchMediaKeyEvent(keyEvent);
- } catch (RemoteException e) {
- Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e);
- }
+ if (USE_SESSIONS) {
+ MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false);
} else {
- Slog.w(TAG, "Unable to find IAudioService for media key event.");
+ IAudioService audioService = IAudioService.Stub.asInterface(
+ ServiceManager.checkService(Context.AUDIO_SERVICE));
+ if (audioService != null) {
+ try {
+ audioService.dispatchMediaKeyEvent(keyEvent);
+ } catch (RemoteException e) {
+ Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e);
+ }
+ } else {
+ Slog.w(TAG, "Unable to find IAudioService for media key event.");
+ }
}
}
}