summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-10-02 10:19:12 -0700
committerGlenn Kasten <gkasten@google.com>2014-10-02 10:19:12 -0700
commite27002d77fc35257f88f1ca0c8f7d444924c1478 (patch)
tree981fac0b9d7464b42973bfb2c05c592e2efc9667 /media
parente4a091bb823f122f7f72c8af57e571dfe06edbf1 (diff)
parent1c92912bcb3e689dd843e7b6a5de9af4d82bd2be (diff)
downloadframeworks_base-e27002d77fc35257f88f1ca0c8f7d444924c1478.zip
frameworks_base-e27002d77fc35257f88f1ca0c8f7d444924c1478.tar.gz
frameworks_base-e27002d77fc35257f88f1ca0c8f7d444924c1478.tar.bz2
resolved conflicts for merge of 1c92912b to lmp-dev-plus-aosp
Change-Id: I5a57218e81dff86f46af7067d47f7af816e2d12c
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 5c2abc5..ffbb48e 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -76,6 +76,7 @@ import android.view.KeyEvent;
import android.view.Surface;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
+import android.view.OrientationEventListener;
import com.android.internal.telephony.ITelephony;
import com.android.internal.util.XmlUtils;
@@ -509,6 +510,8 @@ public class AudioService extends IAudioService.Stub {
// If absolute volume is supported in AVRCP device
private boolean mAvrcpAbsVolSupported = false;
+ private AudioOrientationEventListener mOrientationListener;
+
///////////////////////////////////////////////////////////////////////////
// Construction
///////////////////////////////////////////////////////////////////////////
@@ -617,6 +620,10 @@ public class AudioService extends IAudioService.Stub {
mDeviceRotation = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getRotation();
Log.v(TAG, "monitoring device rotation, initial=" + mDeviceRotation);
+
+ mOrientationListener = new AudioOrientationEventListener(mContext);
+ mOrientationListener.enable();
+
// initialize rotation in AudioSystem
setRotationForAudioSystem();
}
@@ -898,6 +905,25 @@ public class AudioService extends IAudioService.Stub {
return (index * mStreamStates[dstStream].getMaxIndex() + mStreamStates[srcStream].getMaxIndex() / 2) / mStreamStates[srcStream].getMaxIndex();
}
+ private class AudioOrientationEventListener
+ extends OrientationEventListener {
+ public AudioOrientationEventListener(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void onOrientationChanged(int orientation) {
+ //Even though we're responding to phone orientation events,
+ //use display rotation so audio stays in sync with video/dialogs
+ int newRotation = ((WindowManager) mContext.getSystemService(
+ Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
+ if (newRotation != mDeviceRotation) {
+ mDeviceRotation = newRotation;
+ setRotationForAudioSystem();
+ }
+ }
+ }
+
///////////////////////////////////////////////////////////////////////////
// IPC methods
///////////////////////////////////////////////////////////////////////////
@@ -4720,8 +4746,16 @@ public class AudioService extends IAudioService.Stub {
sendStickyBroadcastToAll(newIntent);
}
} else if (action.equals(Intent.ACTION_SCREEN_ON)) {
+ if (mMonitorRotation) {
+ mOrientationListener.onOrientationChanged(0); //argument is ignored anyway
+ mOrientationListener.enable();
+ }
AudioSystem.setParameters("screen_state=on");
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
+ if (mMonitorRotation) {
+ //reduce wakeups (save current) by only listening when display is on
+ mOrientationListener.disable();
+ }
AudioSystem.setParameters("screen_state=off");
} else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
handleConfigurationChanged(context);
@@ -4824,14 +4858,6 @@ public class AudioService extends IAudioService.Stub {
setOrientationForAudioSystem();
}
}
- if (mMonitorRotation) {
- int newRotation = ((WindowManager) context.getSystemService(
- Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
- if (newRotation != mDeviceRotation) {
- mDeviceRotation = newRotation;
- setRotationForAudioSystem();
- }
- }
sendMsg(mAudioHandler,
MSG_CONFIGURE_SAFE_MEDIA_VOLUME,
SENDMSG_REPLACE,