summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-05-21 19:59:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-21 19:59:11 +0000
commit5b53148a4e8d47b88362703445010c54f9fd6ecc (patch)
tree879e7fa812213756a040528de94894f34e061a5c /policy
parentafe18ed6cd409f75315da8e834554a56f0ec4651 (diff)
parent9a9d0b5f6f4be758ed6c8b837a9dd01a451bc0c0 (diff)
downloadframeworks_base-5b53148a4e8d47b88362703445010c54f9fd6ecc.zip
frameworks_base-5b53148a4e8d47b88362703445010c54f9fd6ecc.tar.gz
frameworks_base-5b53148a4e8d47b88362703445010c54f9fd6ecc.tar.bz2
Merge changes I1cbdff1d,I23906b4c
* changes: Handle headsethook voice launching Add 5s timeout to wakelock
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.");
+ }
}
}
}