OSDN Git Service

resolved conflicts for merge of 1c92912b to lmp-dev-plus-aosp
authorGlenn Kasten <gkasten@google.com>
Thu, 2 Oct 2014 17:19:12 +0000 (10:19 -0700)
committerGlenn Kasten <gkasten@google.com>
Thu, 2 Oct 2014 17:19:12 +0000 (10:19 -0700)
Change-Id: I5a57218e81dff86f46af7067d47f7af816e2d12c

1  2 
media/java/android/media/AudioService.java

@@@ -67,15 -68,16 +67,16 @@@ import android.os.UserHandle
  import android.os.Vibrator;
  import android.provider.Settings;
  import android.provider.Settings.System;
 -import android.speech.RecognizerIntent;
 -import android.telephony.PhoneStateListener;
 -import android.telephony.TelephonyManager;
 +import android.telecom.TelecomManager;
  import android.text.TextUtils;
  import android.util.Log;
 +import android.util.MathUtils;
 +import android.util.Slog;
  import android.view.KeyEvent;
  import android.view.Surface;
 -import android.view.VolumePanel;
  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;
@@@ -4719,9 -4190,47 +4745,17 @@@ public class AudioService extends IAudi
                      newIntent.putExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, scoAudioState);
                      sendStickyBroadcastToAll(newIntent);
                  }
 -            } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
 -                mBootCompleted = true;
 -                sendMsg(mAudioHandler, MSG_LOAD_SOUND_EFFECTS, SENDMSG_QUEUE,
 -                        0, 0, null, 0);
 -
 -                mKeyguardManager =
 -                        (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
 -                mScoConnectionState = AudioManager.SCO_AUDIO_STATE_ERROR;
 -                resetBluetoothSco();
 -                getBluetoothHeadset();
 -                //FIXME: this is to maintain compatibility with deprecated intent
 -                // AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED. Remove when appropriate.
 -                Intent newIntent = new Intent(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED);
 -                newIntent.putExtra(AudioManager.EXTRA_SCO_AUDIO_STATE,
 -                        AudioManager.SCO_AUDIO_STATE_DISCONNECTED);
 -                sendStickyBroadcastToAll(newIntent);
 -
 -                BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 -                if (adapter != null) {
 -                    adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener,
 -                                            BluetoothProfile.A2DP);
 -                }
 -
 -                sendMsg(mAudioHandler,
 -                        MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED,
 -                        SENDMSG_REPLACE,
 -                        0,
 -                        0,
 -                        null,
 -                        SAFE_VOLUME_CONFIGURE_TIMEOUT_MS);
              } 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);