summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-06-12 15:49:20 -0700
committerRoboErik <epastern@google.com>2014-06-16 14:00:16 -0700
commit430fc48865e5a371b08f180390946b96d73848fe (patch)
tree8ec38f1d93e87dc7695eee9b89ac017e270c4fa0 /policy/src
parent113af3e59db4b2e474581c68b4b21cea99815f6b (diff)
downloadframeworks_base-430fc48865e5a371b08f180390946b96d73848fe.zip
frameworks_base-430fc48865e5a371b08f180390946b96d73848fe.tar.gz
frameworks_base-430fc48865e5a371b08f180390946b96d73848fe.tar.bz2
Work on removing non-session media routing code
Change-Id: I73e7d22f2f8772c7b07ccf32d962161d79d5db74
Diffstat (limited to 'policy/src')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java19
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java70
2 files changed, 13 insertions, 76 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
index b2ecb61..4ad45a8 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java
@@ -40,9 +40,6 @@ 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;
@@ -294,21 +291,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
}
private void handleMediaKeyEvent(KeyEvent keyEvent) {
- if (USE_SESSIONS) {
- MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false);
- } else {
- 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.");
- }
- }
+ MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 5598972..bc2671011 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -144,9 +144,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false;
- // Whether to use the new Session APIs
- static final boolean USE_SESSIONS = true;
-
static final int SHORT_PRESS_POWER_NOTHING = 0;
static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1;
static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2;
@@ -3974,6 +3971,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
* controlled by this device, or through remote submix).
*/
boolean isMusicActive() {
+
final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
if (am == null) {
Log.w(TAG, "isMusicActive: couldn't get AudioManager reference");
@@ -3982,43 +3980,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return am.isLocalOrRemoteMusicActive();
}
- /**
- * Tell the audio service to adjust the volume appropriate to the event.
- * @param keycode
- */
- void handleVolumeKey(int stream, int keycode) {
- IAudioService audioService = getAudioService();
- if (audioService == null) {
- return;
- }
- try {
- // when audio is playing locally, we shouldn't have to hold a wake lock
- // during the call, but we do it as a precaution for the rare possibility
- // that the music stops right before we call this.
- // Otherwise we might also be in a remote playback case.
- // TODO: Actually handle MUTE.
- mBroadcastWakeLock.acquire();
- if (stream == AudioSystem.STREAM_MUSIC) {
- audioService.adjustLocalOrRemoteStreamVolume(stream,
- keycode == KeyEvent.KEYCODE_VOLUME_UP
- ? AudioManager.ADJUST_RAISE
- : AudioManager.ADJUST_LOWER,
- mContext.getOpPackageName());
- } else {
- audioService.adjustStreamVolume(stream,
- keycode == KeyEvent.KEYCODE_VOLUME_UP
- ? AudioManager.ADJUST_RAISE
- : AudioManager.ADJUST_LOWER,
- 0,
- mContext.getOpPackageName());
- }
- } catch (RemoteException e) {
- Log.w(TAG, "IAudioService.adjust*StreamVolume() threw RemoteException " + e);
- } finally {
- mBroadcastWakeLock.release();
- }
- }
-
final Object mScreenshotLock = new Object();
ServiceConnection mScreenshotConnection = null;
@@ -4201,16 +4162,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (telephonyManager.isOffhook()
&& (result & ACTION_PASS_TO_USER) == 0) {
// If we are in call but we decided not to pass the key to
- // the application, handle the volume change here.
- handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode);
+ // the application, just pass it to the session service.
+
+ MediaSessionLegacyHelper.getHelper(mContext)
+ .sendMediaButtonEvent(event, true);
break;
}
}
- if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) {
- // If music is playing but we decided not to pass the key to the
- // application, handle the volume change here.
- handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode);
+ if ((result & ACTION_PASS_TO_USER) == 0) {
+ // If we aren't passing to the user and no one else
+ // handled it send it to the session manager to figure
+ // out.
+ MediaSessionLegacyHelper.getHelper(mContext)
+ .sendMediaButtonEvent(event, true);
break;
}
}
@@ -4459,18 +4424,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) {
if (ActivityManagerNative.isSystemReady()) {
- if (USE_SESSIONS) {
- MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true);
- } else {
- IAudioService audioService = getAudioService();
- if (audioService != null) {
- try {
- audioService.dispatchMediaKeyEventUnderWakelock(event);
- } catch (RemoteException e) {
- Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e);
- }
- }
- }
+ MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true);
}
}