History log of /frameworks/base/media/java/android/media/AudioService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e5b42d97f6fd3eb0220ea84f21e60d530d93fc46 15-Oct-2014 John Spurlock <jspurlock@google.com> Leave zen when apps set ringer-mode = non-silent (normal/vibrate).

Apps can end up in priority mode by setting ringer-mode = silent.

Now they can leave priority mode by setting ringer-mode = non-silent.
(normal or vibrate)

Bug: 17884168
Change-Id: I54c853885f4ae9ee618041dd7ac6ab0663fc7b37
/frameworks/base/media/java/android/media/AudioService.java
318f0fe43bdc4b2f6764edd91d6b78d9875ffdeb 24-Jan-2014 Jon Eklund <e11237@motorola.com> AudioService: Fix monitorRotation for landscape applications

Current implmentation only sends rotation updates on orientation
changes, so does not handle direct 0<->180 or 90<->270 transitions.

Update rotation based on an OrientationEventListener instead of
Intent.ACTION_CONFIGURATION_CHANGED

Bug 17606902

Change-Id: I01dfcd1c587f5b2e8a96365c2389782ad77936ef
/frameworks/base/media/java/android/media/AudioService.java
ba5270b88798c66fefc17a1b25b27894e4fb7862 02-Oct-2014 Jean-Michel Trivi <jmtrivi@google.com> Full volume on remote submix for apps that need it

If an AudioRecord is created with the "fixedVolume" tag
when recording from REMOTE_SUBMIX, treat the
device DEVICE_OUT_REMOTE_SUBMIX as a fixed full volume
device during the recording. Also register a death
handler during the recording.
Otherwise this is a no-op.

Bug 17635294

Change-Id: I8d26fe777047126f34308e1e1b7ac28ba269ad89
/frameworks/base/media/java/android/media/AudioService.java
5535ea8ef876be25121a6336ffab5a0bf8dbd031 25-Sep-2014 RoboErik <epastern@google.com> Remove BT routes when BT is turned off

A behavior change in the BT stack caused it to stop sending connection
changes for connected devices when you turn BT off. To work around this
we need to remove the connected BT route when BT is turned off.

bug:17512270
Change-Id: I3e5aa8863409c5abac51aa4e93a15f1978cf74b3
/frameworks/base/media/java/android/media/AudioService.java
1a6be6ed3962735f12dbd5ce1bca758120c8fb8d 16-Sep-2014 Jungshik Jang <jayjang@google.com> Adjust volume bar visibility in HDMI-CEC system audio mode

When HDMI-CEC system audio mode is activated.
1. Hide volume bar when volume button is pressed in TV
2. Show volume bar when TV receives volume notification from
Audio Receiver.

Otherwise, (system audio mode off) follows normal TV's behavior.

Bug: 17347499

Change-Id: I1f5bc14285d60d8626a8fbbef9e1959cae7d193b
/frameworks/base/media/java/android/media/AudioService.java
c9ff968787d4744194f9985ebaf8ce7efdd12256 15-Sep-2014 Jungshik Jang <jayjang@google.com> Fix volume change failure in HDMI-CEC system audio mode.

In order to get volume change event, output device should not be
in fixed volume device. This change ignores CEC releated outputs
if system audio mode is on.

Along with this, fix invalid output from getStreamForDevice
as AudioPolicManager does.

Bug: 17502272
Change-Id: I7d4406caea7fa6617f17969dc61aabebb87ecf7d
/frameworks/base/media/java/android/media/AudioService.java
ef9f6f957d897ea0ed82114185b8fa3fefd4917b 13-Sep-2014 Tyler Gunn <tgunn@google.com> Renaming Telecomm to Telecom.

- Changing package from android.telecomm to android.telecom
- Changing package from com.android.telecomm to
com.android.server.telecomm.
- Renaming TelecommManager to TelecomManager.

Bug: 17364651
Change-Id: I192cb5d189f55db012ea72ee82ccc5aedbc21638
/frameworks/base/media/java/android/media/AudioService.java
873cc45da2463a11182fe94a2565364d7e1709bb 12-Sep-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioService: modify stream delay for touch exploration

When accessibility services are running, in particular touch
exploration, the default stream override delay in AudioService
makes it hard for the user to change the notification volume
as when TalkBack speaks, the user would control the media
volume during the utterance, and up until 5s after its end.
Use a shorter delay when touch exploration is enabled.

Bug 17140435

Change-Id: Iabadb9778f2957b5aa0aebd1599f2d69bd83222b
/frameworks/base/media/java/android/media/AudioService.java
d608f3abacb4223c2d6b52db3008039689aa5d55 11-Sep-2014 Terry Heo <terryheo@google.com> Merge "Add a system API to query hdmi system audio mode" into lmp-dev
77a634503f75b58309ad7a7cf669df57f8b477e8 05-Sep-2014 RoboErik <epastern@google.com> Merge "send volume button events to adjustSuggestedStream instead of adjustStream" into lmp-dev
272e161c1a200900cb10b5b0cdab8ae1f123cabd 05-Sep-2014 RoboErik <epastern@google.com> send volume button events to adjustSuggestedStream instead of adjustStream

This way the audio system can route the adjustments correctly when a bt
headset is connected.

bug:17281977
Change-Id: Ic41d038e47179baffc86e539562da285446148c7
/frameworks/base/media/java/android/media/AudioService.java
3512bcd3af103d35c5c3503cecc05fbec053c91f 05-Sep-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "Permission check for entering MODE_IN_CALL" into lmp-dev
ccd654e9d4c38da0d652c442e7a2ca3f447e9abe 04-Sep-2014 Jean-Michel Trivi <jmtrivi@google.com> Permission check for entering MODE_IN_CALL

Make the ability to change the audio mode conditional to having
the MODIFY_PHONE_STATE permission.
Make AudioService's internal implementation of the mode setting
(the setModeInt() method) private, it is only meant to be used
by AudioService.
Refer to the permission names through Manifest.permission, not
by their string value.

Bug 14964198

Change-Id: I49870207566e53d5c8764646cece06d8272f93ed
/frameworks/base/media/java/android/media/AudioService.java
e7d6d97f0d95b9e8982b0d4d9f5e8ce688291940 04-Sep-2014 Terry Heo <terryheo@google.com> Add a system API to query hdmi system audio mode

Bug: 17383620
Change-Id: I75f11619845e5070190414a2bbe967ba85001472
/frameworks/base/media/java/android/media/AudioService.java
9ed982d42d943b373fb8f90841c61be6b2e92659 04-Sep-2014 Jungshik Jang <jayjang@google.com> Rename ro.config.music_vol_steps into ro.config.media_vol_steps.

Bug: 17342612
Change-Id: I77b08a606d26e3d3fd909e28c5ecb9898d214be0
/frameworks/base/media/java/android/media/AudioService.java
e8f8bc0ad6f7f2c657b4360033d2c7571c800ccb 03-Sep-2014 Jungshik Jang <jayjang@google.com> Merge "Make stream_music volume configurable." into lmp-dev
859f4f72720abc62cd51fbe27b960a4661009925 02-Sep-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "Restore permission check for mic muting" into lmp-dev
5f4cfd3ab73f4d8173db05d7c94c098a06cd5f57 02-Sep-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "Move *_AUDIO_PLUG actions from Intent to android.media.AudioManager" into lmp-dev
4a4fea0752c8edd33d680765e97ee3b538d777a5 30-Aug-2014 Jean-Michel Trivi <jmtrivi@google.com> Restore permission check for mic muting

The implementation for AudioManager.setMicrophoneMute() used to
call directly into AudioSystem which called directly into
AudioFlinger and the mediaserver process, where the check for
the MODIFY_AUDIO_SETTINGS is performed.
A regression was introduced by Ib32138bcc256cfbac4fe21a090d5ba34f5c641fc
which calls first into AudioService which runs in system_process
before calling into AudioSystem, which granted the permission.
This CL adds a permission check in this code path when calling
AudioService.

Bug 17259652

Change-Id: I4ac5269262eb90df80ee81db6ec3d96977ee53be
/frameworks/base/media/java/android/media/AudioService.java
32069a1292345b29484079ede47ca92fa87c2448 01-Sep-2014 Jungshik Jang <jayjang@google.com> Make stream_music volume configurable.

AV devices including TV have more fine-grained volume control
for media type (audio and video). But audio service allows
only 15 steps for music type.
This change mimics voice calls approach to make music type
volume configurable.

Bug: 17342612
Change-Id: Ic82ff4d74b29963edfe92975000df07244492ae6
/frameworks/base/media/java/android/media/AudioService.java
c5258433dd353769ccfa2e5e769a7379378a3a0b 28-Aug-2014 Jean-Michel Trivi <jmtrivi@google.com> Move *_AUDIO_PLUG actions from Intent to android.media.AudioManager

For ACTION_HEADSET_PLUG (already in SDK):
- duplicated definition in AudioManager and moved
javadoc there. Javadoc in Intent points to AudioManager.
- the String value is not changed

For ACTION_HDMI_AUDIO_PLUG (being added in SDK):
- moved defintion from Intent to AudioManager
- updated String value to reflect package name "android.media"
instead of using "android.intent"
- added definition of the extras, but removed "name".

For ACTION_ANALOG_AUDIO_DOCK_PLUG,
ACTION_DIGITAL_AUDIO_DOCK_PLUG,
ACTION_USB_AUDIO_ACCESSORY_PLUG,
ACTION_USB_AUDIO_DEVICE_PLUG, all hidden:
- moved definition from Intent to AudioManager,
- changed the value from "android.intent.*" to "android.media.*"

Updated AudioService, UsbDeviceManager and UsbHostManager
to refer to the actions in AudioManager, not Intent.

Bug 17289385

Change-Id: I61dd73140022d2bb9a676a57f595092c8fa89dcc
/frameworks/base/media/java/android/media/AudioService.java
a8528c642090525f0e5f3c35dc3ba5a50ff17093 28-Aug-2014 Julia Reynolds <juliacr@google.com> Merge "Audio/Micrphone user restriction/multiuser updates." into lmp-dev
2b29bc4c1cef64abdf3a68b60bdcf7207193e980 26-Aug-2014 John Spurlock <jspurlock@google.com> Enhance audio service dumpsys.

- Add device name for keys
- Add max volume for streams
- Add missing stream name constant

Bug:16964015
Change-Id: I92facbd8ae49ba299c27bcb10bcf6668fed0d302
/frameworks/base/media/java/android/media/AudioService.java
b53453fae037d67e421011936c8fdffe7ba43922 22-Aug-2014 Julia Reynolds <juliacr@google.com> Audio/Micrphone user restriction/multiuser updates.

1. Persist microphone mute state.
2. Set mute state for correct user.
3. Check for settings restrictions as the correct user.

Bug: 17177502
Bug: 16701642
Change-Id: Id8b6cd90c5caceb67fbec862f90aac7ec7a00b3c
/frameworks/base/media/java/android/media/AudioService.java
27c30e4426302581a266c89d0ef880b340d7b061 27-Aug-2014 Eric Laurent <elaurent@google.com> fix condition to send ACTION_AUDIO_BECOMING_NOISY intent

In checkSendBecomingNoisyIntent(), only output devices
must be taken into account when checking if the device
type is in mBecomingNoisyIntentDevices

Bug: 17298383.
Bug: 16403219.
Change-Id: I2213681184ab9fb3b874029143f2bbd34032d6b8
/frameworks/base/media/java/android/media/AudioService.java
0eb1e402c7e612887e38dc5516f11506b11fd835 22-Aug-2014 Nancy Chen <nancychen@google.com> API review PhoneManager -> TelecommManager. Rename methods (6/6)

PhoneManager
- handlePinMMI docs should explain what a Pin is and what MMI is
- rename isInAPhoneCall to isInCall
- rename showCallScreen to showInCallScreen
- merge this class into TelecommManager, we don't need both

Bug: 16960458

Change-Id: I7d573e27ed093f2ddb7849703cc62f9916835393
/frameworks/base/media/java/android/media/AudioService.java
1d2a1c917f46b6854e91f9867a20abb76ecb794d 14-Aug-2014 RoboErik <epastern@google.com> Merge "Pipe caller's identity through volume methods" into lmp-dev
0dac35af2c6aa42bcd181981b041747cfd1afa5f 13-Aug-2014 RoboErik <epastern@google.com> Pipe caller's identity through volume methods

setStreamVolume and adjustStreamVolume were always being called
from the session service's uid/package. This adds the plumbing to
allow the original app's info to be passed in to the audio service
when volume is changed.

Change-Id: Ib36639dab1e518b435161dc453c8ba9351df3e9b
/frameworks/base/media/java/android/media/AudioService.java
2811dd337262934ea82477f9598f3e49092edb5e 12-Aug-2014 RoboErik <epastern@google.com> Remove REMOTE_STREAM_MUSIC references from AudioService

This removes the fake stream from AudioService and cleans up
references to it. Also removes isLocalOrRemoteMusicActive.

bug:15884752
Change-Id: I1c2b57a2f8ba80061313737f254463f4c80ce8c3
/frameworks/base/media/java/android/media/AudioService.java
34cc4db180c20569e62db5860c0b206be65b5117 13-Aug-2014 Glenn Kasten <gkasten@google.com> Move setting to disable automatic USB routing

This moves the setting from System to Secure per review.

Bug: 16381952
Change-Id: I2497ca66b4f346839490c29295528fac70e94494
/frameworks/base/media/java/android/media/AudioService.java
37d7804627eecaf04e170793c2f5703d5d6d44e8 10-Aug-2014 Jean-Michel Trivi <jmtrivi@google.com> HDMI plug intent and associated information

Read HDMI device information from audio ports and add it as
extras in the connection intent.
Document the new extras in the connection intent.
Make Intent.ACTION_HDMI_AUDIO_PLUG public.

Bug 10549017

Change-Id: I6236b5363f00c433e443195fae8c43af2fc834f7
/frameworks/base/media/java/android/media/AudioService.java
77e54d905f8c0c9925f21a8339a893391179d9d7 11-Aug-2014 John Spurlock <jspurlock@google.com> Talkback: Ensure TTS stream is not affected by ringer mode.

Now that the policy for tablets and phones are unified, follow
the same policy when deciding which streams are never affected
by ringer mode.

Bug:16885683
Change-Id: Iaf526b391de9f429cb9e99ec18a417108443acf6
/frameworks/base/media/java/android/media/AudioService.java
5f5163548424ed3a4d7ea259848f82fb74aaf75d 22-Jul-2014 Glenn Kasten <gkasten@google.com> Add setting to disable automatic USB audio routing

Bug: 16381952
Change-Id: I7335ed4c3ec8d5f9cb9a9bd2a9d2f9e0f3a63c43
/frameworks/base/media/java/android/media/AudioService.java
5f72e168471827b48700d791d6f10b0e53bb18fb 06-Aug-2014 John Spurlock <jspurlock@google.com> Merge "AudioService: getMasterStreamType -> RING on tablets." into lmp-dev
4f0f120316cfcee5880191264885772677fff921 05-Aug-2014 John Spurlock <jspurlock@google.com> AudioService: getMasterStreamType -> RING on tablets.

Since all service-internal checks use stream alias, and the alias
for NOTIFICATION is RING, even on tablets.

This is a followup to ag/506532.

Ensure that #getMasterStreamType always follows the stream_system
alias, and update the system alias for tablets per the new policy.
Update the associate javadoc comment in AudioManager to make this
clear.

Note: there is now no difference in the alias maps between phones
and tablets.

Also fix a condition affected by this in VolumePanel.

Bug:16626879
Change-Id: I2700a48d2a3e7703607f771a1ab7f325596fd789
/frameworks/base/media/java/android/media/AudioService.java
43cc8bbbbd5e6418cdfa0fa4b26c9f5c3a28c029 28-Jul-2014 Jon Eklund <jeklund@motorola.com> Add support for line out audio device

Change-Id: I48750511b56a2bc5f06b7bdd11cfb4e0cd2728af
/frameworks/base/media/java/android/media/AudioService.java
339567d5c91a8dc9228913ed1e5deb0ebb8a4a64 29-Jul-2014 Jean-Michel Trivi <jmtrivi@google.com> Optional AudioService debug logs for setMode()

Add log option to help debug routing / volume issues due to
improper use of audio mode.

Change-Id: I6c2dde61b6b42ea9b45825ba7e10a17a61991c98
/frameworks/base/media/java/android/media/AudioService.java
aa5ee4d65f8788e2a0afcd198367450853fd72ac 25-Jul-2014 John Spurlock <jspurlock@google.com> Volume: Persist unsafe volume playback time.

Instead of warning after every reboot, remember the
playback time after a user confirmation and only
reset after the 20 hour playback threshold.

Bug:16543104
Change-Id: I783358d97b88302a28fe77a8eb88bcd338ef1c87
/frameworks/base/media/java/android/media/AudioService.java
351346092acdfbfcc1d9ebf98d539d2a1196c5e8 25-Jul-2014 John Spurlock <jspurlock@google.com> Volume: Show safe media warning in settings.

If the safe media warning is enabled, make sure
we display it from the new inline slider preference in
Settings (without showing the volume dialog itself).

Also:
- Update the warning dialog to the new sysui theme.
- Separate the warning sentences with an additional line.
- Fix the auto-dismiss timeout.
- Add a system property to additionally enable the safe
media warning for testing
- Add more information to audio service dumpsys.

Bug:15434662
Change-Id: I95fec12c9049bbfdb7ebdf246160e4b12c0c5be3
/frameworks/base/media/java/android/media/AudioService.java
212532b58e3b17d7e9d6e1361946d909d4e372c2 22-Jul-2014 Eric Laurent <elaurent@google.com> AudioService: implement TV system volume

Implement volume policy for TV devices:
- No ringer mode: never silent
- All stream volumes are synchronized: changing any
stream volume will change the volume for all sources.
- Volume is maintained per output device.
- If a CEC capable HDMI sink is connected, digital volume
is maxed out and volume controls are sent to HDMI sink.

Bug: 15759753.

Change-Id: Ic4c38c749ef0440def9635a1669068ccef02a323
/frameworks/base/media/java/android/media/AudioService.java
f2bbad1e7631bbe51c097fe943ab3a1ce346b4cd 24-Jul-2014 Jean-Michel Trivi <jmtrivi@google.com> Remove MediaFocusControl persisting media button receiver

MediaFocusControl doesn't handle media button receivers anymore,
so it should read and persist a receiver, and monitor
package addition/removals.
Also involved a security vulnerability, see bug

Bug 15428797

Change-Id: Ia2be01b20dc4a9820cc0cd3d0605ac03770b266b
/frameworks/base/media/java/android/media/AudioService.java
eb4b8a27e3219726691a868793d2247dc9d2a317 21-Jul-2014 Eric Laurent <elaurent@google.com> AudioService: wait for init completed to handle media server restart

Bug: 16458506.
Change-Id: I25804e6e7209d52fd5dd6c622cae85d1e7d2317f
/frameworks/base/media/java/android/media/AudioService.java
122f599bb4ee0e4767a6a184973efe8e819790ca 21-Jul-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "AudioAttributes for SoundPool" into lmp-dev
55a30c41b6c47d3afe6b13c25c64e8eec9f45e7c 21-Jul-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioAttributes for SoundPool

Add support for building a SoundPool instance and specify
the AudioAttributes.
Remove SRC quality which was never implemented, while leaving
room for supporting it later through the Builder pattern.
Remove stream types.
Update AudioService's use of SoundPool to the new scheme.

Change-Id: Ie51e4008684e5ba25f9b7368098e4f20266a15c7
/frameworks/base/media/java/android/media/AudioService.java
7f4342e5b8e086fc96a4cb4d6df7e4d0bd3256ba 20-Jul-2014 Wonsik Kim <wonsik@google.com> audio: fix too early connection to HdmiControlService

Connect to HdmiControlService on systemReady(), not on constructor.

Change-Id: Ic91467f040fbffa48393e876997bd320ae9500db
/frameworks/base/media/java/android/media/AudioService.java
6a6641cc4f9eefef2d228711a7a57cfcd2b9279c 19-Jul-2014 John Spurlock <jspurlock@google.com> getMasterStreamType from MUSIC -> NOTIFICATION

For non-voice-capable devices to follow suit with the new policy.

Bug:15592574
Change-Id: I5de36de5cfe157702bbdf6918df51a98f3f0051a
/frameworks/base/media/java/android/media/AudioService.java
eb1d88ddf9a0888455c82b83f19da124e5ca6f16 19-Jul-2014 John Spurlock <jspurlock@google.com> Non-voice-capable device default stream is now NOTIFICATION.

Policy change, the volume rocker displayed when nothing else
is going on is now consistent with voice-capable devices.

Bug:15592574
Change-Id: I0f5cb3667b76e1d05286937c702e532f6298ec7c
/frameworks/base/media/java/android/media/AudioService.java
12307ca810e8100981b2b60e3f2c6a7e451b9774 15-Jul-2014 Jungshik Jang <jayjang@google.com> Revisit HDMI-CEC system audio mode in AudioService.

From recent feedback on HDMI-CEC system audio mode,
it would be unnecessary to enforce output from AudioService.
Instead, it would follow audio policy according to status
of HDMI-CEC system audio mode.
For that removed two params of setHdmiSystemAudioModeSupported
api of AudioManager.

In terms of speaker mute, it will be handled by removing speaker
from audio ouput instead of changing gain control. For that
added new force usage type, FOR_HDMI_SYSTEM_AUDIO_MODE and
new force config type, FORCE_HDMI_SYSTEM_AUDIO_ENFORCED.
This is used to notify change of system audio mode to
audio policy manager.

Bug: 16305986
Bug: 16002150

Change-Id: I5643ad093a651c951e12b567c6e11b88aa87cea2
/frameworks/base/media/java/android/media/AudioService.java
f4e51d82d2e34e6832903f01eaecc15ded6c3241 16-Jul-2014 Liejun Tao <L.J.Tao@motorola.com> AudioService: Use device specific mode to open SCO audio

Bluetooth carkit may need specific mode to open SCO
channel. Add a settings value using BT device's MAC address
to store the SCO mode and use it to open SCO. In case no value
is stored, use default mode: Virtual Voice Call.

Change-Id: Iea31a48be0e8f3bd2d8689635fd8ce6f6d6da15a
/frameworks/base/media/java/android/media/AudioService.java
33f4e04e32fac42f158733d6a731e50490fa9951 11-Jul-2014 John Spurlock <jspurlock@google.com> Volume: Delay adjustments made when showing ringer UI.

Since the volume rocker is now the primary system UI for
entering ringer modes, we need to provide a way to display
the ui without making a sound.

Change the policy for the ringer stream to only display the
UI on the initial adjustment request, don't actually make
an adjustment. However, don't break previous ability to
press and hold the vol keys down to vibrate, so allow this
after the standard framework long-press delay.

Audio service had no way of knowing whether or not the registered
volume controller was visible, so add a mechanism for the
controller (volume panel) to send that info back to the service.

Found and fixed a discrepancy between AudioManager.handleKeyDown
and MediaSessionLegacyHelper so that an adjustment over the
keyguard is allowed to vibrate as well as play sound during
adjustments.

Bug:16202639
Change-Id: Icd36c23e8d08c4ed57922c05724b281f32049be7
/frameworks/base/media/java/android/media/AudioService.java
a8b6bd88cfb010c9e9aa1339e504fd593919e1e0 01-Jul-2014 Jean-Michel Trivi <jmtrivi@google.com> Define audio policy, mixes, and mixing rules

An AudioMixingRule is a collection of AudioAttributes and match/exclude
rules.
An AudioMix is defined by its AudioMixingRule, AudioFormat and
routing flag.
An AudioPolicyConfig is a collection of AudioMix and is
parcellable.
An AudioPolicy has an AudioPolicyConfig, and
can be registered/unregistered through AudioManager.

bug 16009464

Change-Id: I01bf95d014967f48ba823648ea897779da099e5d
/frameworks/base/media/java/android/media/AudioService.java
6f34f5ab8ab1b1db7887e5405d8b0031e105ab05 08-Jul-2014 Jungshik Jang <jayjang@google.com> Revamp HDMI-CEC system audio mode integration with audio service.

In previous change we use setForceUse(FORCE_MEDIA, XXX) method
in order to set specific audio output type, such as LINE, HDMI_ARC,
and SPDIF. But it turns out that it conflicts with bluetooth
a2dp which uses the same setForceUse(FORCE_MEDIA, yyy).

This change is based on several conditions.

1. When other non-speaker devices are on, prevent system audio
from turing on.
2. In order to keep track of other devices' connectivity and to
turn off system audio if other device like bluetooth or
headphone preempts current output, register OnAudioPortChangeListner
to audio manager.
3. All possible system audio outputs can be merged with other
outputs without priority.

Change-Id: Id4e47d99db64b9f77a17c2c28c47787ab8980bf7
/frameworks/base/media/java/android/media/AudioService.java
6bd096c8d608197535a6a6a26663fd1e717246de 10-Jul-2014 John Spurlock <jspurlock@google.com> Volume: allow dialog to play sound over keyguard.

Now that we are allowing the volume dialog above the keyguard,
the old suppression rule does not apply.

Bug:16186697
Change-Id: I071f1a2856850218e267d1fbaf547db44b644382
/frameworks/base/media/java/android/media/AudioService.java
ae641c9ccd3f81214cee54a5f13804f1765187ad 01-Jul-2014 John Spurlock <jspurlock@google.com> Implement new volume UI design.

- Add segmented zen-mode picker to the rocker UI.
- Add a new "no interruptions" value to the zen setting.
- Implement expandable condition subpanel on the rocker UI.
- Remove the old circle&slash icons.
- Suppress alarm sounds if in "no interruptions" mode.
- Add warning re: alarms to the condition UI.
- Allow rocker UI to display over the keyguard.
- Remove Notifications QS tile.
- Realign volume rocker to the top of the screen.
- Add support for new "days" sleepMode.
- New icon policy rules for "volume" slot.
- New important icon (star).

Associated Settings change:
I6ed56791784968adfbd684f490dbbebed285a2dd

Bug:15831713
Change-Id: I35afe38646f04d2ba0dbac11c2c6356120a33694
/frameworks/base/media/java/android/media/AudioService.java
41d974631c5f525da49c88d34cecedd5a4cfeda8 30-Jun-2014 Jungshik Jang <jayjang@google.com> Add volume callback for Hdmi-Cec system audio mode.

Hdmi-Cec's system audio mode delegates audio control to
audio receiver from tv. It requires to delegate
volume change including mute to audio receiver
instead of consuming by tv.
In order to do this this change introduces three apis.
One is added to IAudioService, the others are added
to IHdmiControlService as hidden apis.

1. IAudioService#setHdmiSystemAudioSupported;
This is to notify system audio mode change to audio
service so that it determines to notify volume or mute
change to HdmiControlService.

2. IHdmiControlService#setSystemAudioVolume;
This is to notify volume change to HdmiControlService.
It's called only where system audio mode is on.

3. IHdmiControlService#setSystemAudioMute;
This is to notify volume change to HdmiControlService .
It's called only where system audio mode is on.

Change-Id: I3d8534b37ddf1a812e32012059a8778772044bf0
/frameworks/base/media/java/android/media/AudioService.java
e19a4fe32fd87a6c819f15155bb43d9fbe67607a 01-Jul-2014 Santos Cordon <santoscordon@google.com> Merge "Move call-related SystemAPIs to TelecommManager. (1/3)"
9eb45934c582a0bf5060125690de8bce4f10ca76 27-Jun-2014 Santos Cordon <santoscordon@google.com> Move call-related SystemAPIs to TelecommManager. (1/3)

Bug: 15672803
Change-Id: I46e448fe93a9c5b4ae013e8b2fd6f0ce89b94e69
/frameworks/base/media/java/android/media/AudioService.java
fb917e019f04d60f4924114fe2684c0d67981af6 27-Jun-2014 Paul McLean <pmclean@google.com> Enabling USB Device and Android Device Vol inc/dec functionality for USB Audio Output

Bug: 13747844

Change-Id: Ia969dad4150adeafb375e3f9985f9d8ba7222638
/frameworks/base/media/java/android/media/AudioService.java
d09bd0c6eb8318e0122b14d7eb5324e481706e41 25-Jun-2014 RoboErik <epastern@google.com> Move VolumeController into AudioService

VolumeController was a hidden class only used by AudioService and
MediaFocusControl. Since we added a public VolumeProvider class
moving VolumeController to avoid confusion.

Change-Id: I6838daf9b83846e1393b1a8502d3b10345a4799a
/frameworks/base/media/java/android/media/AudioService.java
19c9518f6a817d53d5234de0020313cab6950b2f 24-Jun-2014 RoboErik <epastern@google.com> b/15729204 Pipe sessions through to VolumePanel

When remote volume is changed via volume buttons we need to notify
the system UI so it can show the slider. This also passes it the
controller to use so adjustments to the slider are sent back to
the correct session.

Change-Id: If5847bcd5db16c56e0e9904b88c94e5b28954c41
/frameworks/base/media/java/android/media/AudioService.java
6f0e4ddd66fcdcc13944d8970d0b560e2626508b 18-Jun-2014 RoboErik <epastern@google.com> Remove more dead audio service code

Hit a snag in remote volume changes. Trying off this round of
removal so I can work on fixing remote volume handling in a
separate CL.

Change-Id: I49b1ba4b75d770ba7c77da081755f3210a9e9483
/frameworks/base/media/java/android/media/AudioService.java
83900754f357616b9e56eaf7fc85f49b8906e987 16-May-2014 Eric Laurent <elaurent@google.com> AudioManager: add startBluetoothScoVirtualCall()

Add API to start bluetooth SCO audio connection explicitly
in virtual call mode.

Bug: 11824396.
Change-Id: I1dfab13c659f5855e0b78467ac48b3186af7874c
/frameworks/base/media/java/android/media/AudioService.java
d3c8642dae9a1f6db60e2f8e5c7b32cd1b3169df 16-Jun-2014 RoboErik <epastern@google.com> Remove some more old code and fix Media command

Removes some more hidden apis from AudioService/Manager. This also
fixes up Media.java to support commands for the new service to help
with debugging. Also fixes a couple bugs that were found while fixing
up Media.

Change-Id: I68e4aa80a4de430b98236aafc883664b9432c62b
/frameworks/base/media/java/android/media/AudioService.java
430fc48865e5a371b08f180390946b96d73848fe 13-Jun-2014 RoboErik <epastern@google.com> Work on removing non-session media routing code

Change-Id: I73e7d22f2f8772c7b07ccf32d962161d79d5db74
/frameworks/base/media/java/android/media/AudioService.java
22c921a910d236abf3a1705a02541a49fdaf3a14 28-May-2014 Emily Bernier <ember@google.com> Add an app ops code for microphone muting.

When OP_AUDIO_MICROPHONE (linked to the DISALLOW_UNMUTE_MICROPHONE user
restriction) is set, the system blocks calls to setMicrophoneMute.

Bug: 13585692

Change-Id: Ib32138bcc256cfbac4fe21a090d5ba34f5c641fc
/frameworks/base/media/java/android/media/AudioService.java
4a21b25fad62e4f19d13ba814263841c931f56ef 04-Jun-2014 Julia Reynolds <juliacr@google.com> Allow profile and device owners to change and get the master volume mute state.

Also protect muting master volume with op code OP_AUDIO_MASTER_VOLUME.
Bug: 13585918
Change-Id: I91fe7ee60cd291cca15966b3127c0bb8a4828f6a
/frameworks/base/media/java/android/media/AudioService.java
41792644d911f88e48ee7a9e34e6ddfbf35b46ef 01-Jun-2014 John Spurlock <jspurlock@google.com> am bfea31fd: VolumeZen: Prevent raising ringer volume in silent mode.

* commit 'bfea31fd6dd88c94deae1122874b4e0737380d25':
VolumeZen: Prevent raising ringer volume in silent mode.
a11b4affcad3d255aa723a89b768ea222506f2e8 01-Jun-2014 John Spurlock <jspurlock@google.com> VolumeZen: Prevent raising ringer volume in silent mode.

Instead of breaking out of silent mode when raising the volume
using the keys, prevent the change and display a visual hint up
in the user interface.

Bug:15330217
Change-Id: I74aae44319aadcd6db9841c7799967607f5a1617
/frameworks/base/media/java/android/media/AudioService.java
7b587884baeb98ca13b37f3034bd4e26881252c8 30-May-2014 Eric Laurent <elaurent@google.com> Merge "indicate in and out audio device connection separately"
ae4506e9b5fc3e0c6d9862fbc05b9af7d6742a6e 30-May-2014 Eric Laurent <elaurent@google.com> indicate in and out audio device connection separately

Modified AudioService and WiredAccessoryManager to use separate
device connection indications for input and oputput devices in case
of combined devices like wired headset or BT SCO headset.

Change-Id: Ifebaaab177191e2f505824420a13998d7a424aec
/frameworks/base/media/java/android/media/AudioService.java
0a40ec2192e4836b2fcb6ba51a7688aa6bd4ee98 21-May-2014 Mike Lockwood <lockwood@google.com> Add Audio Manager support for Bluetooth A2DP Sink profile

Change-Id: Iff6035e85faf52647cc41a59f98ba2924300eb8d
/frameworks/base/media/java/android/media/AudioService.java
53bd26335c52c2e86e50f0bac90ec4ae2a91da8e 27-May-2014 John Spurlock <jspurlock@google.com> am c5890bb9: Merge "VolumeZen: combine ringer/notification volume and zen." into lmp-preview-dev

* commit 'c5890bb9c2361adf64efa7a2680536edaa527d1f':
VolumeZen: combine ringer/notification volume and zen.
8600534df66c2ff5846ed230b50c56229322d48a 23-May-2014 John Spurlock <jspurlock@google.com> VolumeZen: combine ringer/notification volume and zen.

- Implement a new volume panel widget, combining volume and
zen mode + conditions.
- Show zen mode + conditions when modifying ringer or notification
streams.
- Host the volume panel widget in a dialog when being controlled
by the audio service / volume keys.
- Remove support for multiple sliders in the volume panel.
- Remove support for separate ringer + notification volumes
in the volume panel.
- Move volume panel resources up to SystemUI.
- Create a new combined Notifications quick settings tile.
- Host the volume panel widget in the quick settings panel under
Notifications.
- When the quick settings detail panel is visible, route the volume
keys to the embedded widget instead of showing a redundant dialog.
- Create common styles for quick settings text to be closer to spec.
- Update the framework resources for the ringer stream.
- Show the ringer icons in global actions.
- Add "until you turn this off" back as a separate zen condition.
- Disable time condition buttons when they are N/A.
- Don't allow volume changes to set ringer mode silent.

Bug:15186070
Change-Id: Id5e321dd1d5e7c4cf3917027ffbdf7e80d38b00d
/frameworks/base/media/java/android/media/AudioService.java
6b02c898f59a13eb91fd795d74468680e25ddfae 23-May-2014 Eric Laurent <elaurent@google.com> am 5231cb4b: am b928b7c2: am ba64d298: Merge "AudioService: fix cross deadlock in VolumeStreamState"

* commit '5231cb4bfbdd20200555f263ee73b439e33d1ec0':
AudioService: fix cross deadlock in VolumeStreamState
b928b7c2bf12a5dbd31b08d244b0ff8d2a9851c1 23-May-2014 Eric Laurent <elaurent@google.com> am ba64d298: Merge "AudioService: fix cross deadlock in VolumeStreamState"

* commit 'ba64d298bee228b8e27ea17fb31fbff4b4188304':
AudioService: fix cross deadlock in VolumeStreamState
fdbee869be504e399efce1127a68281bd9b158c5 13-May-2014 Eric Laurent <elaurent@google.com> AudioService: fix cross deadlock in VolumeStreamState

Synchronize modifications of volume index by VolumeStreamState
class mutex instead of using synchronized methods.
This avoids possible cross deadlock when modifying volume on
two stream types simultaneously and one is slave to the other.

Bug: 13730145.

Change-Id: I13406c71010ce0c2e2f08f660b6101f310396c98
/frameworks/base/media/java/android/media/AudioService.java
3346a802087f621c6441bc512dfcc17b07143fc6 20-May-2014 John Spurlock <jspurlock@google.com> VolumeZen: SystemUI now hosts the volume dialog.

- Allow SystemUI to set the volume controller interface using
a new binder call to audio service.
- Remove VolumePanel's dependency on AudioService.
- Host the base VolumePanel in the SystemUI process.

Change-Id: I095d5a1a579d42b68d0f81abb4087bd0c754b876
/frameworks/base/media/java/android/media/AudioService.java
c0e439f1b7dcd937b6cc842eafc7a4e7c8abce9b 20-May-2014 Eric Laurent <elaurent@google.com> Merge "AudioSystem: add new audio device definitions"
948d32748caaac5be06c991ebf00f74265a7849f 17-May-2014 Eric Laurent <elaurent@google.com> AudioSystem: add new audio device definitions

Change-Id: Ib7675bc33771365b2dbb7694c522469317b11457
/frameworks/base/media/java/android/media/AudioService.java
8a2cfc309ab9126e90022916967c65a793c034f0 16-May-2014 RoboErik <epastern@google.com> Move media key processing to sessions

Send all media key events over to the MediaSessionService instead
of AudioManager. This does not affect volume handling yet, so it
is possible to get into a state where volume will be handled by
a different thing than media buttons. Except for corner cases
this shouldn't be noticable.

Change-Id: I00a576175d9c82937f0836e509b9a98d5cb77b83
/frameworks/base/media/java/android/media/AudioService.java
4a5eeb9c727d77bb57fef87a70c8c9cc23dbfee3 06-May-2014 Eric Laurent <elaurent@google.com> AudioService/WireAccessoryManager: change boot completion detection method

BOOT_COMPLETED intent is not a reliable way for system services
to detect boot completion. The intent broadcast can be significantly
delayed and there is no guaranty that system services
receive it before apps.

Use a systemReady() method called by SystemServer instead.

Bug: 14323903.
Change-Id: I781596a3545e7a1e719799982347cbcd9a4c9009
/frameworks/base/media/java/android/media/AudioService.java
559c76dbc37ff25b204ed1f060d3ec2fa43d718c 01-May-2014 Natalie Silvanovich <natashenka@google.com> Bounds Check in onPlaySoundEffect

Prevents system crash

Bug: 13514877
Change-Id: Id03561779611d9eb7402ff206fd877b39bb2f035
/frameworks/base/media/java/android/media/AudioService.java
df3614693dd4fe52a116dcd28bd74eae80818a4f 11-Apr-2014 Paul McLean <pmclean@google.com> Implement USB Audio across Nexus Devices
Fix issues with connecting non-audio USB devices.

https://b.corp.google.com/issue?id=13745966
https://b.corp.google.com/issue?id=8281454
https://b.corp.google.com/issue?id=13751080
https://b.corp.google.com/issue?id=4643412

Change-Id: I1186f69a6c5f50279a1225a77fb5d4f7a8eda3cb
/frameworks/base/media/java/android/media/AudioService.java
c837a451946b64d70ed7c642fbde03c182c28b6f 09-Apr-2014 Paul McLean <pmclean@google.com> Revert "Revert "Initial implementation of USB Audio output.""

This reverts commit f2f80c09b668176b3b1e619457ae628432636507.
/frameworks/base/media/java/android/media/AudioService.java
f2f80c09b668176b3b1e619457ae628432636507 08-Apr-2014 Eric Laurent <elaurent@google.com> Revert "Initial implementation of USB Audio output."

This reverts commit 3af0fe0c9df2fc1e0a4d6bcd827a4d7aa28dbdeb
while investigating issues 13751080 and 13883978.

Bug: 13751080.
/frameworks/base/media/java/android/media/AudioService.java
6f127c9b6c249ca1cd17c07a8476edd0fcc1f04d 01-Apr-2014 Paul McLean <pmclean@google.com> Merge "Initial implementation of USB Audio output."
3af0fe0c9df2fc1e0a4d6bcd827a4d7aa28dbdeb 02-Dec-2013 Paul McLean <pmclean@google.com> Initial implementation of USB Audio output.

Change-Id: I7fbbe421285d628fa49591c6469ac50efec77ccf
/frameworks/base/media/java/android/media/AudioService.java
167d1a27713ab64cd3c0aa70de96434083ef0400 24-Jul-2013 Glenn Kasten <gkasten@google.com> Fix typo

Change-Id: I7c2fb560b8d8778afad237aadd97e8e94dd865e7
/frameworks/base/media/java/android/media/AudioService.java
1af30c7ac480e5d335f267a3ac3b2e6c748ce240 10-Mar-2014 John Spurlock <jspurlock@google.com> Add stream-level suppression to vibrate/audio services.

- Add new audio restriction layer to app-ops. Restrictions add
additional constraints to audio operations at a stream-level.
Restrictions do not affect the persistable state, and are purely
additive: that is, they can only impose additional contstraints, not
enable something that has already been disabled. Restrictions
also support a whitelisted set of exempt package names.

- Add new audio stream-level checks to app-ops.

- Implement a provisional OP_PLAY_AUDIO suppression to three
java entry points MediaPlayer, AudioTrack, & SoundPool.

- Enhance vibrator api to take stream information as an optional
hint - the constants correspond to AudioManager stream types.
OP_VIBRATE now supports the stream-level restriction check.

- Simplify Vibrator subclasses by adding default implementations
for two .vibrate calls.

- Migrate NoMan's zen-mode control to use the new app-ops
stream-level restriction mechanism.

Change-Id: Ifae8952647202f728cf1c73e881452660c704678
/frameworks/base/media/java/android/media/AudioService.java
10a07a043f7fa47148ae2cc2fcd6b0edeb52190b 14-Mar-2014 Marco Nelissen <marcone@google.com> Merge "Verify certificates" into klp-dev
7e435a011dd519f76a8ec1a8ed99a22bee5c3e26 13-Mar-2014 Marco Nelissen <marcone@google.com> Verify certificates

b/13418320

Change-Id: I39c81b1557a16c7a4666a4531a398efa91dcb00c
/frameworks/base/media/java/android/media/AudioService.java
7fb580ea4ddbf3d406610485fd7e5fbf25cdef21 11-Jan-2014 Zhihai Xu <zhihaixu@google.com> DO NOT MERGE setAvrcpAbsoluteVolume is passed wrong unit parameter from AudioManager

setAvrcpAbsoluteVolume is passed wrong unit parameter from AudioManager.
It cause maximize volume in Bluetooth speaker/device.
The volume expected by Bluetooth Avrcp should be from 0 to 15.
But the current volume parameter passed to Bluetooth Avrcp is from 0 to 150.
It is scaled by 10 times than the correct volume.
index = rescaleIndex(index * 10, streamType, streamTypeAlias);
Should divide the volume by 10 before pass to Bluetooth Avrcp.

bug:12495379
Change-Id: I4160588e92ee384e21a75d63036d8bd6ccb30621
/frameworks/base/media/java/android/media/AudioService.java
93899a5972f7ad2defd51f46f039e39613c6f7f6 11-Jan-2014 Zhihai Xu <zhihaixu@google.com> Merge "setAvrcpAbsoluteVolume is passed wrong unit parameter from AudioManager"
2f4a2b139b4c1dde7be1d14333ad02553734c528 11-Jan-2014 Zhihai Xu <zhihaixu@google.com> setAvrcpAbsoluteVolume is passed wrong unit parameter from AudioManager

setAvrcpAbsoluteVolume is passed wrong unit parameter from AudioManager.
It cause maximize volume in Bluetooth speaker/device.
The volume expected by Bluetooth Avrcp should be from 0 to 15.
But the current volume parameter passed to Bluetooth Avrcp is from 0 to 150.
It is scaled by 10 times than the correct volume.
index = rescaleIndex(index * 10, streamType, streamTypeAlias);
Should divide the volume by 10 before pass to Bluetooth Avrcp.

bug:12495379
Change-Id: I0432f83ca4a0c134244d96b2eea14d7168e9a9ff
/frameworks/base/media/java/android/media/AudioService.java
6090995951c6e2e4dcf38102f01793f8a94166e1 19-Nov-2013 John Spurlock <jspurlock@google.com> Remove unused imports from frameworks/base.

Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
/frameworks/base/media/java/android/media/AudioService.java
cd772d04345850e160a45613fcf6b86da0dce4cf 31-Oct-2013 Eric Laurent <elaurent@google.com> AudioService: fix notifications with A2DP abs volume

When A2DP absolute volume is enabled, the music stream
software volume is maxed out because the headset applies
the volume.

We must also max out other streams playing over A2DP otherwise
they are attenuated twice and are barely audible.

Bug: 11316102.
Change-Id: I7e58c74cb683ad1d6f3b68abb0ef967c817fbf4f
/frameworks/base/media/java/android/media/AudioService.java
fca1e603236b8d1681f784e77e3719d1d59c1428 11-Oct-2013 Jean-Michel Trivi <jmtrivi@google.com> Remote volume changes

When the user plays media remotely, and presses on the volume
keys with the screen off, verify whether not only local playback
is active, but also if remote playback is active to see if
the volume should be adjusted.
When adjusting the volume with screen off, adjust the remote
volume if applicable.

When controlling volume, give priority to local media playback.

Bug 11169862

Change-Id: I88a8c003969177d50d4c1569ec6cd2a7c153a341
/frameworks/base/media/java/android/media/AudioService.java
bacb5422bc4670d2b8905d9f58d068a97836561f 07-Oct-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Also rely on enabled notification listeners for RemoteController registration" into klp-dev
f108cdd9ee5efe354d87edd02a07b323298c116c 28-Sep-2013 Jean-Michel Trivi <jmtrivi@google.com> Also rely on enabled notification listeners for RemoteController registration

Registration of a RemoteController may succeed only if:
- the caller has the MEDIA_CONTENT_CONTROL permission,
- or if the RemoteController.OnClientUpdateListener it
registers if one of the enabled notification listeners.

For using the "enabled notification listener" functionality,
the CL involved:
- making OnClientUpdateListener an interface so a 3rd-party
application may have its implementation extend
NotificationListenerService, which is required for a
listener to be enabled by the user.
- add the concept of "enabled" status in an
IRemoteControlDisplay, so a RemoteController (which
encapsulates the IRemoteControlDisplay implementation)
may be registered, but later temporarily disabled by
the user, as a result of a user action in the security
settings, or a user switch.
- making MediaFocusControl, the component tied to
AudioService, monitor changes in enabled notification
listeners, and act upon enable/disable changes.

Bug 8209392

Change-Id: Ia8dfa2156c65668b2b0d4ae92048005912652d84
/frameworks/base/media/java/android/media/AudioService.java
24e0d9b6c40712a297e4c287435a3b0fdd30e9da 04-Oct-2013 Eric Laurent <elaurent@google.com> audioservice: fix DTMF stream volume

DTMF stream must also be muted by silent mode when following ring
stream volume in order to be properly muted and unmuted when ringer
mode changes.

Also fix a problem in VolumeStreamState.setAllIndexes() when some
devices are not present in the stream state from which indexes
are copied.

Bug: 10932676.
Change-Id: I373d0fd1a475980786d97d97348d46a7e7421461
/frameworks/base/media/java/android/media/AudioService.java
a4dfbdc54d8898491d3a7d1d9d818c7db3fd773d 01-Oct-2013 Eric Laurent <elaurent@google.com> audioservice: always acquire wake lock as AudioService

When a wake lock is aquired while executing a binder call and released
in the message handler, AppOps complains about the uid mismatch.

Clear the binder identity before acquiring the wake lock.

Bug: 10627124.
Change-Id: Ibd5babc1ae699bffde1a659562089eb091879106
/frameworks/base/media/java/android/media/AudioService.java
7ddd226e7c6e759feaf2747a90be1cc06acf37a3 02-Sep-2013 Jean-Michel Trivi <jmtrivi@google.com> RemoteController class to expose IRemoteControlDisplay features

Wrap all the features of IRemoteControlDisplay.aidl in a
new class, RemoteController, that implements the
IRemoteControlDisplay interface.

The API functions to expose in the SDK are tagged with
"CANDIDATE FOR API"

Bug 8209392

Change-Id: I597bcd503ac93e73889c9ae8b47b16c4fcb363bc
/frameworks/base/media/java/android/media/AudioService.java
c9d1d5f35091226e96fcfa91817480f589eb36e2 12-Sep-2013 Matthew Xie <mattx@google.com> Adjust absolute volume only when the device is streaming music

The device has to be A2DP device
Remove AudioManager#avrcpUpdateVolume
bug 10681804

Change-Id: I2bc85e48fdff374638b984af593c6f1c4ddd3ee6
/frameworks/base/media/java/android/media/AudioService.java
198bc229c37fc65c7b61f1452345fb1da9c385b6 22-Aug-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Ratings for RemoteControl" into klp-dev
f823fc4dba2df5cf5f00e13361f2db93c81f6961 20-Aug-2013 Jean-Michel Trivi <jmtrivi@google.com> Ratings for RemoteControl

Add support for metadata of a RemoteControlClient that can be
updated:
- methods to control which keys can be edited,
- interface for an application to receive new values for a key.

Add definitions for ratings.
A rating is:
- a value between 0 and 100
- or a value indicating there is no rating
For a same piece of content, a rating can come from:
- the user
- "others" (i.e. not the user), to provide an average rating
Rating styles are:
- heart (a toggle)
- thumb up / down
- stars (with a configurable maximum number of stars)

Rating by user is editable metadata.

Bug 8440498

Change-Id: I1d45972f9ace4cb505ee0757e917f1d5dedd264e
/frameworks/base/media/java/android/media/AudioService.java
7337bee7839238f244fad31112a45389f6ef907c 01-Mar-2013 Johan Gustavsson <johan1.gustavsson.x@sonymobile.com> Updating Force Use toggling for Communication use case

setForceUse toggling is shaky when toggling either through
setSpeakerphoneOn and setBluetoothScoOn. Depending on call sequence
an application may unintentionally trigger a routing use case it
does not want.
The main root cause is that neither of these calls take the
previous state into account. A call to setSpeakerPhoneOn will for
example partly disable any active BT SCO routing.

Change-Id: I436ee5a8da2d9ea5a2e4e89eec083c8118a5ff7e
/frameworks/base/media/java/android/media/AudioService.java
dfb881f96af7898151940a4bbc52e45e6043d38b 18-Jul-2013 Eric Laurent <elaurent@google.com> AudioSystem: new audioflinger restart detection

Add a specific method to AudioSystem for AudioService to poll
for AudioFlinger service restart instead of relying on current
callback mechanism which is flaky.

Bug: 9693068.
Change-Id: Id21d142a22b257205700201978cce1cb8b15180d
/frameworks/base/media/java/android/media/AudioService.java
194c140c34d9f4874c64839c2e20ef61f41cbb97 20-Aug-2013 Jeff Brown <jeffbrown@google.com> Merge changes Id3815fe8,I90a85921 into klp-dev

* changes:
Define AudioSource.REMOTE_SUBMIX.
Remove setRemoteSubmixOn method.
f15ef4b02cf2e4298a6eca9709693f1e720c18c6 10-Aug-2013 Jeff Brown <jeffbrown@google.com> Remove setRemoteSubmixOn method.

The submix will be controlled automatically from now on based on
whether there is an active audio recorder.

Bug: 10265163
Change-Id: I90a8592136c6507680e70f054243df70cc82efad
/frameworks/base/media/java/android/media/AudioService.java
5a0cf7a27f3953a1266af48543ccd9024f4cd89f 19-Jul-2013 John Du <johnldu@google.com> Adding support for Absolute Volume

Change-Id: I7bbc6f9296221ca219a50a5e377ebac9dcf5a407
/frameworks/base/media/java/android/media/AudioService.java
2380566debfc57eb1cc07db1306ccee23b84ddd4 31-Jul-2013 Jean-Michel Trivi <jmtrivi@google.com> Notification muting conditional to exclusive audio focus request

Summary of feature:
Do not mute notifications when speech recognition recording is
active, but when an app has requested audio focus with
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE.

Implementation:
Move definition of AUDIOFOCUS_NONE to AudioManager where other
audio focus codes are defined.
Add support for querying the current audio focus type.
When audio focus is requested as GAIN_TRANSIENT_EXCLUSIVE, make
the corresponding loss by LOSS_TRANSIENT.
Before playing a notification, check whether GAIN_TRANSIENT_EXCLUSIVE
has been requested.

Bug 8251963

Change-Id: I41edc77326b70639d2fdcb4642c53109995b72a8
/frameworks/base/media/java/android/media/AudioService.java
fa9a69805b001034aa04c3b33989a7ac21522371 28-Jun-2013 Jean-Michel Trivi <jmtrivi@google.com> Refactor for audio focus, remote control, media button handling

Extract audio focus, remote control and media button handling
outside of AudioService without any changes in functionality.
Moving logic to new class, MediaFocusControl.
Introduce interface for managing volum control logic, VolumeController.
The VolumePanel class implements this interface.

Change-Id: I72bda2e0670c26e61ff076fd729c15f9f1156dc5
/frameworks/base/media/java/android/media/AudioService.java
fd116ad1ab02f6060a0b2201f018317fa32e28b4 13-Jul-2013 Glenn Kasten <gkasten@google.com> Inform AudioFlinger of device's low RAM attribute

to help it configure it's memory

Bug: 9798886
Change-Id: Ia2df59cfcb76f5ff48cca92b107915e2adde899c
/frameworks/base/media/java/android/media/AudioService.java
bfdad8ecad06f855c8facf72177b0f01919ff629 08-Jul-2013 Jaekyun Seok <jaekyun@google.com> Add a keycode to switch audio tracks (1/2)

A key to switch audio tracks is general on media devices like blu-ray.

Bug: 9728155
Change-Id: Ib61822b8aa9c143a8febc3cff4707fa775119448
/frameworks/base/media/java/android/media/AudioService.java
905c2b11172de4852e4af713bc5656c4135fc2c2 31-May-2013 Jean-Michel Trivi <jmtrivi@google.com> am 7d2e3939: am c1d47c50: Merge "Monitor device rotation" into jb-mr2-dev

* commit '7d2e3939964fb6512f370059a33206d2c9ec7a0e':
Monitor device rotation
bb6f8711a7f804d39c45218db2d6339940cc5d35 24-May-2013 Jean-Michel Trivi <jmtrivi@google.com> Monitor device rotation

If requested by ro.audio.monitorOrientation property, set orientation
information as audio system parameter on configuration changes.

Bug 9095903

Change-Id: I669d4084eade3c14feb63f644bdd5b74fddc8857
/frameworks/base/media/java/android/media/AudioService.java
ba50b97cff80e73620a0e3d13cae169e095974a7 01-May-2013 Dianne Hackborn <hackbod@google.com> Add new app ops for various interesting audio service things.

Media buttons: note when an application tries to take ownership
of the media buttons.
Audio focus: note when an application tries to take audio focus.
Volume levels: note changes to the volume level of the various
streams.

Maybe we should also have some ops for muting streams, soloing
streams, etc?

Change-Id: I79a5d477b0bad4ff61486cdb73ffb1196a674964
/frameworks/base/media/java/android/media/AudioService.java
ea236f19e652942a7af384566c70cdd0c7f88c58 23-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Identify in logs launch of voice search from key events" into jb-mr2-dev
c3c4babf8424f65b3d3d2700f60fae6e94e9cd00 19-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Opt-in mechanism for RemoteControlClient position anti-drift check

RemoteControlClient has an interface for the framework to query
the playback position. This mechanism is used to detect
when the estimated position drifts from the real position by
having the framework regularly poll (every 15s when playing at
1x) this interface and compare against the estimation.
But this mechanism:
- should only be used when IRemoteControlDisplay implementation
care about position display
- should not be used by default because the implementation of
the position query interface might involve network traffic
in some remote media player implementation for instance.

This CL implements an opt-in mechanism to be used by
implementators of IRemoteControlDisplay, to request the
anti-drift mechanism to be turned on.

bug 8120740

Change-Id: I1baa3e515546ac41e0ac9c3a41bfa3147ecf3d7f
/frameworks/base/media/java/android/media/AudioService.java
924f1b962c3a8e700a695cb65cb07c17cf90c696 20-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Identify in logs launch of voice search from key events

Clearly identify in the logs when AudioService starts one of
the following two intents in response to long-press on
the KEYCODE_HEADSETHOOK key: ACTION_WEB_SEARCH and
ACTION_VOICE_SEARCH_HANDS_FREE.

Bug 8095981

Change-Id: I14ca99533dfb011cdc530c0bafd8104ff2436c7d
/frameworks/base/media/java/android/media/AudioService.java
c18c9138cee0f0859bcab636a004ce92ca4a9ab5 13-Apr-2013 Eric Laurent <elaurent@google.com> AudioService: SCO audio backward compatibility

After commit 25fc29b3, AudioManager.startBluetoothSco()
does not use virtual voice call mode anymore when starting the
SCO audio connection to the headset.
To help backward compatibility, this change makes that virtual voice call
is used if the request comes from an application targeting a SDK version
before JB MR2. For applications targeted to JB MR2 and above a raw SCO
audio connection is established.

Bug 8157702

Change-Id: If1ded2fd99b7ed76d2435d95ee03659e78a7882a
/frameworks/base/media/java/android/media/AudioService.java
8515256ad477721a97108745da4c86f378f50637 10-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Handle seek requests in AudioService" into jb-mr2-dev
3fbf67e217fb489fe7318a9e43d8ae86646eb4cc 09-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Handle seek requests in AudioService

AudioService handles seek requests to RemoteControlClients.
Discard old or unprocessed seek requests when handling a new one.
Update javadoc for OnPlaybackPositionUpdateListener interface.

bug 8120740

Change-Id: Id17c2852b24d4b8af85e472a177484b98cfeba05
/frameworks/base/media/java/android/media/AudioService.java
bc948101043b3c4b57eb6e0e2421494fd7c1d41e 08-Apr-2013 Dianne Hackborn <hackbod@google.com> Merge "Have audio service clean up new receivers in crashing processes." into jb-mr2-dev
79f7ec70ebd5758ce54fd5b6fcd60fd27457cba6 05-Apr-2013 Dianne Hackborn <hackbod@google.com> Have audio service clean up new receivers in crashing processes.

The new media button receiver with only a pending intent (no
component name) could be left hanging if the process that
registered it went away. These semantically need to be tied
to the calling process's lifetime; we now clean them up when
the calling process goes away.

Also added some additional cleanup of media button receivers
when packages change (updated, cleared).

And on top of that, a new "media" command for doing media
things. Currently lets you send media keys and monitor
remote display data.

Oh and finally added a new BaseCommand base class for
implementing these command line utilities.

Change-Id: Iba1d56f10bab1eec4a94a7bb1d1c2ae614c8bcf5
/frameworks/base/media/java/android/media/AudioService.java
25fc29b3691a1d2a84164988dc74b2e7d301868e 05-Apr-2013 Eric Laurent <elaurent@google.com> AudioService: do not use virtual call for bt sco

Do not use startScoUsingVirtualVoiceCall() BluetoothHeadset
API to connect SCO audio. This will cause headsets to act as if an incoming
call was received which is not what we want for voice commands.

Bug 8157702

Change-Id: I271909d4d1f3822758740a8484e3d2d8b4f34c00
/frameworks/base/media/java/android/media/AudioService.java
6a5702041f48f868863a0454d7df6cd64eab235d 03-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "RemoteControlClient receives playback position change requests" into jb-mr2-dev
c3c7b92a8128831445d2a185b0986c60d929b150 02-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Clean up role of component name in media button event receiver" into jb-mr2-dev
3261b537c5fdec824575a1f6ad6d8942715e82e2 01-Apr-2013 Jean-Michel Trivi <jmtrivi@google.com> RemoteControlClient receives playback position change requests

RemoteControlClient defines two listener interfaces for playback
position, one to let the framework query the current playback
position, the other to request playback to seek to a given
position.

Updated IRemoteControlDisplay interface to support passing info
about whether the user of RemoteControlClient can provide a
playback position, and receive a new one.
Updated implementations of IRemoteControlDisplay to new
interface.

Bug 8120740

Change-Id: I1a5a969da4d0f8c9ad27f691919dd08f8653982b
/frameworks/base/media/java/android/media/AudioService.java
742647c809622703207c34171d482c562e34b10b 02-Apr-2013 Eric Laurent <elaurent@google.com> Merge "AudioService: removed last audible volume index" into jb-mr2-dev
42b041ed4f184e3af7f788eb07307f556a2a6616 29-Mar-2013 Eric Laurent <elaurent@google.com> AudioService: removed last audible volume index

Removed storage of last audible stream volume index.
This information is redundant because we already have
two pieces of information (current volume and mute state)
allowing to completely define which volume should actually
be applied by the framework or indicated to apps.

The last audible index management had anyway been broken by
successive changes making that the value stored could be 0
in some cases causing problems like issue 8109149 when
restoring the volume settings from the DB.

Bug 8109149

Change-Id: Iea80f5a994554e42d45b227f651ec9646844aa77
/frameworks/base/media/java/android/media/AudioService.java
b839b83c7349533b4cb7278fd3d792b47199ba36 30-Mar-2013 Jean-Michel Trivi <jmtrivi@google.com> Clean up role of component name in media button event receiver

A public API was added to AudioManager to register a media button
event receiver whithout having to supply a ComponentName.
This CL updates the comments that specified that the now optional
ComponentName parameter can be null, and never persist the button
event receiver is there is no ComponentName to persist.
Also unregistering the media button receiver makes no use of
the ComponentName anymore.

Change-Id: Idcfed1e2a85feb6fa178ca7797427f238705957c
/frameworks/base/media/java/android/media/AudioService.java
6f2683698ea1b316ae49623a7e9a13d9d9b53f71 30-Mar-2013 Jean-Michel Trivi <jmtrivi@google.com> Fix RemoteControlStackEntry constructor in AudioService

Add missing call to constructor of RccPlaybackState to initialize
the mPlaybackState field of the RemoteControlStackEntry class.

bug 8512601

Change-Id: I636d5c1b416d6a3d3808d5be53c9c544ab293732
/frameworks/base/media/java/android/media/AudioService.java
bc43b4c2f24fd03c0d0546895c97918c1736d9fb 22-Mar-2013 Jean-Michel Trivi <jmtrivi@google.com> RemoteControlClient can report current position, speed

Extend RemoteControlClient class to support reporting the
current playback position, and the playback speed.
Define listener for an application to receive new playback
position to seek to (use of listener to be implemented).
Update IRemoteControlDisplay implementations to new interface.

bug 8120740

Change-Id: I2654daeca1ac49713d325df8226dceb85943c020
/frameworks/base/media/java/android/media/AudioService.java
6b5e22d52c69cb6d80ff09bd32395b0034ada343 29-Mar-2013 Eric Laurent <elaurent@google.com> audio service: fix BT SCO intent permission again

Commit 2a57ca93 did not address the calling permission
for setMode() method which can also indirectly call
BluetoothHeadset APIs.

Bug 8242429

Change-Id: I8483c0492836192f47984c48629291cb261b001b
/frameworks/base/media/java/android/media/AudioService.java
5d3eb44a749ece55ce345f9d8ac608fc3715f9da 21-Mar-2013 Eric Laurent <elaurent@google.com> AudioService: rewrite sound effects loading

Handle all access to SoundPool in the message Handler to
synchronize load/unload and play requests.

Add a timeout to load operations in case a problem occurs while loading
a sample and the SoundPool callback is not called.

Bug 6633095

Change-Id: I39949e4c8b2f7ca2d8b760b1f92c7e0fcd0a46e1
/frameworks/base/media/java/android/media/AudioService.java
7c566bf3e4a10d74588b3e92ea3f6af310930f37 25-Mar-2013 Eric Laurent <elaurent@google.com> Merge "audio service: add config option for fixed volume" into jb-mr2-dev
961cae92540763226648813d111c5b5c3b0f1597 20-Mar-2013 Dianne Hackborn <hackbod@google.com> New media button API.

This allows sending media buttons to any PendingIntent,
so they can be captured with a registered receiver.

Also add some new ViewTreeObserver APIs; this is all for
a new support library API to watch media buttons while an
app has input focus.

Change-Id: I3c51cef59460662b008c9a2cc87d6a6383c21855
/frameworks/base/media/java/android/media/AudioService.java
83a017b6b7c099d1a0293e5839be6477325aef06 20-Mar-2013 Eric Laurent <elaurent@google.com> audio service: add config option for fixed volume

Add a boolean configuration option config_useFixedVolume indicating if
stream volumes or master volume can be modified.
If the option is true, the AudioManager volume and mute APIs will be no ops and the
volumes will be maxed out.
To be consistent:
- the ringer mode is forced to normal and cannot be modified
- volume panel is never displayed
- volume settings are not available
- ringer mode global action is not displayed.

The default for this option if false.

This is useful for a class of devices intended for connection to a digital
audio output only, where the volume is directly controlled on the audio sink.

Bug 8161458

Change-Id: I2571d5ee79952ef0914d8fd1985816467a80adcd
/frameworks/base/media/java/android/media/AudioService.java
e78fced559d879b2e37b610d0d9a89daf08f0f2b 16-Mar-2013 Eric Laurent <elaurent@google.com> audio service: allow touch sounds customization

Added audio_assets.xml resource listing the
audio asset files for each touch sound effect.
This resource can be overlayed to customize the
touch sounds for a given device.

Bug 8339000

Change-Id: I8c156f0ce7f8769a58d77442fbd9c46b57c202e9
/frameworks/base/media/java/android/media/AudioService.java
f5a1fc3c0fd733acd21e1437f153ba27220be8ce 12-Mar-2013 Eric Laurent <elaurent@google.com> audio service: fix regression in startBluetoothSco

Commit 2a57ca93 introduced a regression in startBluetoothSco()
where the calling pid was cleared before creating the entry for
the client app. The pid in the entry was always the system server pid
and the SCO client verification logic was broken preventing the activation
of the BT SCO connection.

Change-Id: I4e024b22fceb350f829ff0d8664703faeef7af48
/frameworks/base/media/java/android/media/AudioService.java
7c8aeadd9a010b79c04261f0a9092942d1db0dc2 12-Mar-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Support multiple IRemoteControlDisplay" into jb-mr2-dev
4a5700556191c835116ec2a6997a4f16f464ac9d 04-Mar-2013 Jean-Michel Trivi <jmtrivi@google.com> Support multiple IRemoteControlDisplay

Modify RemoteControlClient and AudioService to support multiple
simulataneous IRemoteControlDisplay interfaces active at the
same time.

Change-Id: I9f200a488afdd62a5e6957e64624d745e0f28149
/frameworks/base/media/java/android/media/AudioService.java
2a57ca931fefe817b6110101289721acaacfc808 08-Mar-2013 Eric Laurent <elaurent@google.com> audio service: fix BT SCO intent permission

Clear calling identity before calling BluetoothHeadset
methods from binder call.
Also send BT SCO audio state intents from the
message handler, not from binder calls.

Bug 8242429

Change-Id: I742ba8dc47a258dbee6fb9d57db302f2bffaafd7
/frameworks/base/media/java/android/media/AudioService.java
26bf4d9020dcb16327e91044cda78b3baef723b5 11-Jan-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Optimize media button stack traversal for remote volume"
8c02884c8c3c97cdc2366ac187c8a326308b895b 10-Jan-2013 Fabrice Di Meglio <fdimeglio@google.com> Fix Volume icons for RTL languages

- add mirrored version of the icons
- make VolumePanel respond to layout direction changes
- make AudioService propagate layout direction changes to the VolumePanel

Change-Id: Ibb884ab81641c319a9b7bea1381066f3f19581f0
/frameworks/base/media/java/android/media/AudioService.java
5df0e6ad26d201d18e2143c14d661e8fecb8272a 07-Jan-2013 Jean-Michel Trivi <jmtrivi@google.com> Optimize media button stack traversal for remote volume

Iterate over entries in the media button stack from the top
for remote volume-related operations as the stack entry being
looked for is more likely at the top of the stack.

Change-Id: Iaa2685ebb297d2184dd2c63498d7bd2b811ce744
/frameworks/base/media/java/android/media/AudioService.java
a578c48e6c8677bcb54340aadb9470f8a275e56c 28-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Use playback state to update remote control stack

The remote control stack in AudioService is responsible for handling
which application receives media button events. When an application
"registers" its media button receiver, it gets placed at the top
of the remote control stack. If the app also has audio focus (is
at top of focus stack), this will also cause the information of
the attached remote control client (RCC) to be displayed on the
lockscreen.
If an app doesn't re-register its button receiver when it wants
to receive the button events, it might have lost its place at the
top of the remote control stack, and would not show up in the
lockscreen anymore.
This change consists in using the playstate reported by the RCC
to change the remote control stack. If an RCC reports a "playing"
state (e.g. playing, fast forwarding), it is safe to assume the
application is actively being used, and should be the one that
receives the transport control buttons. This CL uses the reported
playstate to conditionally move the corresponding stack entry
to the top of the stack.

Bug 7311023

Change-Id: I1505f01664c16e108b22d33e3f47f0056343676e
/frameworks/base/media/java/android/media/AudioService.java
84aa61e2a838fdeb7484ffaf95945a205bccb453 27-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Optimize remote control stack traversal order

Iterate of remote control stack entries from the top of the stack
for cases where the condition being checked is more likely at
the top of the stack, as opposed to the bottom, which is first
accessed when using an iterator.

Change-Id: I625bee59021c2d652e9d6355b48dc0c11e36093f
/frameworks/base/media/java/android/media/AudioService.java
66cbd197376a0bfe976544c428f55c2e6b8e12c9 27-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Add comments on remote control stack traversal order

Add comments to justify where remote control stack traversal order
doesn't matter.

Change-Id: I71a71ae22446cee529649e047142c774f78a377b
/frameworks/base/media/java/android/media/AudioService.java
ed2d10dab78c2ac040391d9ae64764378b18b34d 27-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Updates to remote control client (un)registration

Iterate over the remote control stack from top to bottom
when (un)registering a remote control client (RCC).
When unregistering an RCC, stop traversing the stack when
match found. If match was at top of the stack, update
the remote control display (RCD).

Change-Id: If64acf102bdf328085d707f9e0f7e86cf4d4001a
/frameworks/base/media/java/android/media/AudioService.java
bc83425c116694b60fde0d9ae6314339c7b8fe2f 27-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix stack traversal order when removing or adding media button receiver

Iterate over the media button receiver stack from top to bottom
when removing or adding a receiver.
Update comments and name to reflect that the corresponding methods
must be synchronized on audio focus and remote control.

Change-Id: I1fb7f682a999aa66d92d56ca6ecd8b37eeff8ac9
/frameworks/base/media/java/android/media/AudioService.java
c30f45b97f0aeefef05f51208f54eafa3499e40b 26-Dec-2012 Jean-Michel Trivi <jmtrivi@google.com> Add comments in AudioService focus and media button stack traversal

Add comments to reflect where and why the audio focus and media
button stacks are traversed with an iterator, which traverses
the stack from bottom to top.

Change-Id: I462a522195e742295d13eff5fc727e59a5d7e830
/frameworks/base/media/java/android/media/AudioService.java
942de41bb1b2e14388055cfd0a3645394277b5da 06-Dec-2012 Eric Laurent <elaurent@google.com> Merge "more fixes on safe volume warning message"
f94942f1b947c0d56bac0ffcc7ccfe95c443ebe7 06-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Import only what's needed"
fde16d5879ea88a971004c984093409468b6139c 03-Dec-2012 Eric Laurent <elaurent@google.com> more fixes on safe volume warning message

Fixes the following problems with safe headphone volume warning message:
- Do not display the warning dialog when screen is off.
- Use the same 3 second timeout as for the volume slider to dismiss the dialog.
- Do not dismiss the warning dialog when touching outside of the slider window
but inside the warning window.
- Disable the volume slider when the warning message is displayed.
- When setting volume directly (touching the volume slider), and the warning
is displayed, save the requested volume and apply it if acknowledged by the user.
- Do not display the warning message when restoring safe volume after 20h of
cumulative listenening

Bug 7658641.

Change-Id: Ib3d1315193a433dad918aa5df78fa071062b2394
/frameworks/base/media/java/android/media/AudioService.java
3ef7549876a159dae1568429edcb57e4e7d08459 28-Nov-2012 Eric Laurent <elaurent@google.com> Allow mute when playing over fixed volume device

Modified AudioService to add the possibility to mute/unmute music
with volume keys while playing over fixed volume devices (HDMI, digital dock).
VOL- forces volume to 0 and VOL+ forces volume to maximum.

Bug 7377764.

Change-Id: Ibaf805d76c30e3c0e395547cd3ce0087dbfb9f30
/frameworks/base/media/java/android/media/AudioService.java
b686eceac9655f26694847d79683c09aaeaeedf2 30-Nov-2012 Eric Laurent <elaurent@google.com> am b46857d2: am b1f45c4a: am c3eb57b2: Merge "AudioService: improve initial safe volume delay" into jb-mr1.1-dev

* commit 'b46857d228edc53878e738ffd484dea1acf44baf':
AudioService: improve initial safe volume delay
c3eb57b22f930f07448e877f0814eb5659bfc3c5 30-Nov-2012 Eric Laurent <elaurent@google.com> Merge "AudioService: improve initial safe volume delay" into jb-mr1.1-dev
05274f348e12983eb8613cc6eb9ae561e8197e28 29-Nov-2012 Eric Laurent <elaurent@google.com> AudioService: improve initial safe volume delay

AudioService relies on a valid mmc in order to enforce the headset
volume limitation or not. There is a timeout to enforce the limitation
if no mcc is configured after boot.
Until this timeout is reached or a valid SIM is detected the headset
volume is not limited.

This change makes that the last known volume limitation state (enforced or
not) is persisted so that next time we boot, last known state is applied until
a new mcc is configured if any. In most cases, the mcc does not change from one
boot to the next and we do the right thing. If teh mcc does change, the correct
policy will be enforced when the mcc is detected or after the timeout.

Also fix a bug where the volume panel was not displayed if the limitation mechanism
is triggered at the first press on VOL+ key.

Bug 7455275.

Change-Id: Id0f2996d893d38c6a14f4f9e4a0e9e3be17ef127
/frameworks/base/media/java/android/media/AudioService.java
9121a032bb11256deabca709a42f7212ea19feaa 22-Jun-2012 Glenn Kasten <gkasten@google.com> Import only what's needed

Change-Id: I93e86e36569496b4bd08f58a8681e6471341ad3d
/frameworks/base/media/java/android/media/AudioService.java
0572954507b6f8ea124ddce657eb310ff5ab481e 21-Nov-2012 Jean-Michel Trivi <jmtrivi@google.com> am 015ec39d: am 5985d106: am c7dd6640: Merge "Fix audio focus evaluation order for display update" into jb-mr1.1-dev

* commit '015ec39dffe54687781357f9ef751b6218159c5d':
Fix audio focus evaluation order for display update
4dd3fb3e2c2b0d3dd7cb18f9e7e40a7b9dee8692 21-Nov-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix audio focus evaluation order for display update

Change 1f9196a8e5de9b004e61afabc70b18caf7cf9c7e introduced
an issue when trying to ignore audio focus entries in the
stack that don't use the music stream, or are for transient
audio focus gain, for remote control display updates.
The bug was that the audio focus stack traversal was not
starting from the top, as it should. It was using
the iterator order, which, in the case of a stack, starts
with the bottom-most entry.
The fix consists in traversing the stack from the top, i.e.
from the last element of the vector used to hold the stack
entries.

Bug 7311023

Change-Id: I0c1900dbf98599a621a420ab55531a3eee838fe5
/frameworks/base/media/java/android/media/AudioService.java
068225de0197df07a0247b2877666ea91c22c992 28-Feb-2012 Glenn Kasten <gkasten@google.com> Add all-channel setVolume() API

Add combined channel APIs setVolume to AudioTrack, MediaPlayer, and
SoundPool to make later migration easier, and encourage apps to use
that API. The new APIs are @hide for now.

Change-Id: I0c87bfdbff4f4292259fa33e65f67badbafd270b
/frameworks/base/media/java/android/media/AudioService.java
0214f2b8560928d3160a938f3edde4d3aa03c6c5 05-Nov-2012 Eric Laurent <elaurent@google.com> AudioService: undock audio glitch - DO NOT MERGE

merge from master:

"AudioService: improve low end dock audio control

Low end docks have a menu to enable use of audio
for media: automatically enabling/disabling use of audio
when the dock is connected/disconnected is useless
and can be the source of audio glitches.

Bug 7463620."

Change-Id: I3b7e7ebe660bb3f0e4367d2a3ed63ee76f78fe58
/frameworks/base/media/java/android/media/AudioService.java
cd3231f501b7ee038af5ab378ee5550090b7bc2e 03-Nov-2012 Eric Laurent <elaurent@google.com> audio service fix dock after crash - DO NOT MERGE

merge from master:
"audio service: set dock use on mediaserver restart

Restore forced usage of dock audio for media according to
current setting when media server restarts."

Bug 7485250.

Change-Id: Ie67b80ede1ed92d223dd96de83c1beb985dfba06
/frameworks/base/media/java/android/media/AudioService.java
08ed1b9d2099ec8231b21353b33b901492ea9885 05-Nov-2012 Eric Laurent <elaurent@google.com> AudioService: improve low end dock audio control

Low end docks have a menu to enable use of audio
for media: automatically enabling/disabling use of audio
when the dock is connected/disconnected is useless
and can be the source of audio glitches.

Bug 7463620.

Change-Id: I3b7e7ebe660bb3f0e4367d2a3ed63ee76f78fe58
/frameworks/base/media/java/android/media/AudioService.java
bff5ca576ef55bfdd51a0d2ff39f4bac614fa728 03-Nov-2012 Eric Laurent <elaurent@google.com> audio service: set dock use on mediaserver restart

Restore forced usage of dock audio for media according to
current setting when media server restarts.

Change-Id: Ie67b80ede1ed92d223dd96de83c1beb985dfba06
/frameworks/base/media/java/android/media/AudioService.java
61ebf9cd8f0b7bfbad6840bb828f2300beef745d 29-Oct-2012 Eric Laurent <elaurent@google.com> Merge "audio service: make dock audio is off by default" into jb-mr1-dev
f4a8eb22112c534f436357b50f231778c5c15c25 29-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> No playback and music widget from other user on user switch

On user switch:
- make the current audio focus owner loose audio focus
- clear the remote control display

Bug 7205290
Bug 7307156

Change-Id: I6ebcb94d1d2bae8c57ab98dd7e795b239a981d28
/frameworks/base/media/java/android/media/AudioService.java
5ba0ffa0237a5c300545e4c72591613c6e5b2ed9 29-Oct-2012 Eric Laurent <elaurent@google.com> audio service: make dock audio is off by default

It is better to turn dock audio off by default if the user
has not yet explicitly turned it on from the settings menu.
There is a discoverability issue with current implementation
as we do not launch the settings menu at first dock insertion.
Having audio routed to the dock by default would make the tablet
silent for media content when docked and users will not be directed
to the settings menu.

As the dock audio enable setting is for low end docks only
(analog connection and no jack detection) disabling audio for low end docks
by default does not impact manta and prime docks.

Bug 7302106.

Change-Id: I571f361d41940cfb811f038442ae9ba9c6361d1d
/frameworks/base/media/java/android/media/AudioService.java
7ee1e4ff7346a278a6722108fbc1869240b3e866 27-Oct-2012 Eric Laurent <elaurent@google.com> add settings for dock audio enabled

Add settings dock_audio_media_enabled indicating if dock audio
is enabled for media for docks that do not implement jack detection.

Bug 7302106.

Change-Id: I75766b606ceb870b3f89979c4e3cca88ed197aaf
/frameworks/base/media/java/android/media/AudioService.java
d799db406b0bace285b7a82a468f75887f0308b6 24-Oct-2012 Eric Laurent <elaurent@google.com> AudioService: add fix for corrupted settings

Added correction of MODE_RINGER_STREAMS_AFFECTED setting in
case it is inconsistent when read from the database: ringtone,
notification and system streams are always affected by ringer mode.
A corruption of this setting persists accross reboots and propagates via
backup/restore causing devices to play notification and ringtones in silent mode.

Bug 7384750.

Change-Id: I23170413d01e6a8e34ef514f1516d7b9ab8bc656
/frameworks/base/media/java/android/media/AudioService.java
8d9a1f66d9d3dbbd45a56d441a746ec11dba7645 19-Oct-2012 Jeff Sharkey <jsharkey@android.com> More migration to Global settings.

Bug: 7375796
Change-Id: I3954ce141ad30073896090a28eee743ba15fd736
/frameworks/base/media/java/android/media/AudioService.java
c203ecfd9f6c356542fcb10bc85b27b98b170ddf 11-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> Use device availability to start WFD audio routing

Don't use the force_use mechanism to start WFD audio routing,
but rather only the availability of the remote submix audio
device. This is matched by a change in the audio policy
manager.

Bug 7318180

Change-Id: I756f032d8ca0375c3dbeddb7c321261c497539bc
/frameworks/base/media/java/android/media/AudioService.java
dd45d01128423a82652a3c9d77fa393631d95229 08-Oct-2012 Eric Laurent <elaurent@google.com> enforce camera sound according to country code

Use mcc config overlay mechanism to enforce camera shutter sounds
in countries where it is mandatory.
Property ro.camera.sound.forced is not needed anymore.
When camera sound is forced, STREAM_SYSTEM_ENFORCED is removed from
streams affected by ringer mode and its volume is
maxed out. AudioSystem.FORCE_SYSTEM_ENFORCED is sent to audio
policy manager to alter the routing policy for STREAM_SYSTEM_ENFORCED.

Also fix streams being unmuted when settings are reloaded
upon user switch while in silent mode.

Add ringer mode to audio service dump.

Bug 7032634.

Change-Id: Iceea5bba3b8d3aabf8e42b222deb33a893dc8f38
/frameworks/base/media/java/android/media/AudioService.java
33902db75011d863009585682bd08560c5b89a75 08-Oct-2012 Eric Laurent <elaurent@google.com> AudioService: fix settings for fixed volume device

Force max volume for devices with fixed volume policy (HDMI, dock...)
when reading the settings from DB. Otherwise, these devices would
get the default volume which is not what we want.

Also fix a problem related to ringer mode management when reloading the
volume settings upon user switch that would cause a muted stream to be
unmuted.

Bug 7301563;

Change-Id: I81cdb97125b845da584ed680181b93c7c1e5903f
/frameworks/base/media/java/android/media/AudioService.java
31fed73701041cd5455942abe2dacfc7639c5370 04-Oct-2012 Eric Laurent <elaurent@google.com> Merge "AudioService: filter flags in volume methods" into jb-mr1-dev
799448bee167c046ed715c7c4e3fe3486bf80d43 25-Sep-2012 Eric Laurent <elaurent@google.com> AudioService: filter flags in volume methods

Strip FIXED_VOLUME flag in setStreamVolume() and
adjustStreamVolume() as this flag is reserved for
framework use.

Bug 4335692.

Change-Id: I507582270f4c4cd631ee81fe50dca895bb6352b3
/frameworks/base/media/java/android/media/AudioService.java
002e9d382d2daa7ed41636463ecdbddbd4897aba 02-Oct-2012 Eric Laurent <elaurent@google.com> audio service: fix system volume settings

STREAM_SYSTEM stream volume is never persisted to settings as
it is always derived from another stream volume (STREAM_RING on phones
and STREAM_MUSIC on tablets). Therefore values stored in settings
are stale from previous releases and should be ignored.

Also fix a problem where a muted stream can be unmuted by
readAudioSettings() even if it is muted by ringer mode.

Bug 7216630.

Change-Id: If23561ddfbc704f89fd0a997faf1b50299a50c2e
/frameworks/base/media/java/android/media/AudioService.java
d640bd325c3be9a350058c835b880a7e0b40dc60 29-Sep-2012 Eric Laurent <elaurent@google.com> enable safe media volume according to country

Enable safe headphone volume feature for all countries that
do not opt otherwise in their mmc configuration.
Opt out for US.

Bug 7231029.

Change-Id: I2619d627508eb2cd1f73db9242e0cb5efa839a2a
/frameworks/base/media/java/android/media/AudioService.java
4bbcc6549738f3d69831b2bd9eb4accec3e9920e 24-Sep-2012 Eric Laurent <elaurent@google.com> Display a fixed volume silder when docked.

Align UI indication to volume policy when docked: the music volume
cannot be adjusted when docked or connected to HDMI. Display
a disabled slider at max volume in this case to be consistent.

Bug 4335692.

Change-Id: I6f8db143b0e2ecf54e4bdacd88afdeb661a98a18
/frameworks/base/media/java/android/media/AudioService.java
bf2e088b008cdc80059b943c3b144ec982963f4e 25-Sep-2012 Jean-Baptiste Queru <jbq@google.com> Merge into jb-mr1-dev

Change-Id: Iba23d16643b8754f6e0a7288b2ca242f722f1bdd
5bfaeaef3fc348d66f48b86be08655e91dff910a 22-Sep-2012 Eric Laurent <elaurent@google.com> pause music playback when switching user.

AudioService sends AudioManager.ACTION_AUDIO_BECOMING_NOISY
intent when notified of a user switch to pause music playback
for all background users.

Bug 7128886.

Change-Id: I6a24409533bf40c517c43da25b9baeceb3379cb8
/frameworks/base/media/java/android/media/AudioService.java
9903e2638a6c502d96413680d3ebae4fb77fc412 22-Sep-2012 Eric Laurent <elaurent@google.com> Volume keys control music volume after music stops

On phones, add a short delay during which volume keys still
control music volume after music has stopped. This is similar
to the tablet behavior for notifications volume.
It allows users to control the prompt volume for talk back,
voice search or navigation even after the prompt has stopped.

Bug 7162364.

Change-Id: Iffbca9ec30ebcbe5846f783ddd260b6e736caf2b
/frameworks/base/media/java/android/media/AudioService.java
f1a457d06c53a901ea08d2d3fb6e766bc06c4d4f 21-Sep-2012 Eric Laurent <elaurent@google.com> Do not turn safe volume on upon headset connection

It is not a requirement to force headphone volume limitation
back on when a headset is plugged in. Only turn it back on
when the device is power off or after 20 hours of cumulative
music listening.

Bug 7064975.

Change-Id: Idabd417a9a9b8096552119c0ff528ba193cfdb5d
/frameworks/base/media/java/android/media/AudioService.java
f9fac2c5fe3f304ee866b1afc3191d36835e96bd 20-Sep-2012 Eric Laurent <elaurent@google.com> Merge "Add multi user volume management" into jb-mr1-dev
bc0fab1fc2db832ef86d8a33466ec4d68b103ca0 19-Sep-2012 Eric Laurent <elaurent@google.com> Add multi user volume management

Notification and Alarm volumes are per user: they are saved and restored
when the foreground user changes.
Media volume is global: it is still saved and restored per user for
implentation reasons but is copied from one user to the next to ensure
media playback volume continuity when switching users.

Ringer mode (silent, vibrate...) is now a global setting.

Bug 7128886.

Change-Id: I9f4f5a0a3985552bca61c2cc3bbe5a144db755a6
/frameworks/base/media/java/android/media/AudioService.java
db45484e4b5858d14da93d3a06311b93bf0cf320 18-Sep-2012 Mike Lockwood <lockwood@google.com> AudioService: Send "becoming noisy" intent when USB accessory audio is disconnected

Bug: 7051259

Change-Id: I5b5fb3ad7c7e38dbf49700d893fd49354eaecf51
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
c34dcc1e1ebf152bb400abbb8bc25f7dc0c3ba97 10-Sep-2012 Eric Laurent <elaurent@google.com> headphone volume limitation

Limit music volume when headphones or headset are inserted.
Display warning message when user wants to increase the volume
above a platform specific volume and request user acknowledgement
before proceeding.

TODO: exact wording of the warning message must be defined by UX.

Change-Id: I00f429f602534c6d8783126b929371c4d432e6e2
/frameworks/base/media/java/android/media/AudioService.java
2ac2afeac989ea1dc326b0db996d6c6c8e00cc29 21-Aug-2012 Jean-Michel Trivi <jmtrivi@google.com> Add support for controlling remote submix audio routing

Add method in AudioManager to control remote submix through
AudioService.
AudioService controls remote submxi: enabling/disabling
remote submix will:
- make the sink audio device available/unavailable
- make the audio source available/unavailable
- force/unforce media streams to be routed to WFD

Change-Id: I05d9cc7c3e8a720318ec1385737cbd46a21a3207
/frameworks/base/media/java/android/media/AudioService.java
73365695e4d169126c6932df8e8e932aefe6aaca 30-Aug-2012 Dianne Hackborn <hackbod@google.com> Merge "Improve multi-user broadcasts." into jb-mr1-dev
5ac72a29593ab9a20337a2225df52bdf4754be02 30-Aug-2012 Dianne Hackborn <hackbod@google.com> Improve multi-user broadcasts.

You can now use ALL and CURRENT when sending broadcasts, to specify
where the broadcast goes.

Sticky broadcasts are now correctly separated per user, and registered
receivers are filtered based on the requested target user.

New Context APIs for more kinds of sending broadcasts as users.

Updating a bunch of system code that sends broadcasts to explicitly
specify which user the broadcast goes to.

Made a single version of the code for interpreting the requested
target user ID that all entries to activity manager (start activity,
send broadcast, start service) use.

Change-Id: Ie29f02dd5242ef8c8fa56c54593a315cd2574e1c
/frameworks/base/media/java/android/media/AudioService.java
794da7a0543cbecffefb73794aa68d1a93e41adf 30-Aug-2012 Eric Laurent <elaurent@google.com> AudioService: pause music when undocked

Send becomming noisy event also when disconnecting a dock
(analog, digital or USB) or HDMI.

Bug 6760590.

Change-Id: I497df35a3c6817d2b300f532d4cc3f12e3ce9ace
/frameworks/base/media/java/android/media/AudioService.java
1f9196a8e5de9b004e61afabc70b18caf7cf9c7e 27-Jul-2012 Jean-Michel Trivi <jmtrivi@google.com> Relax rules for media apps to stay on RemoteControlDisplay

The playback of notification would make the display of the
RemoteControlClient disappear from the lockscreen.

Fixed by modifying which AudioFocus owner to consider when
reevaluating how the RemoteControlDisplay needs to be updated:
use the first (starting from the top of the AudioFocus stack) that
uses STREAM_MUSIC, or that uses any other stream type for a short
period.

Change-Id: Id7cef00c5eed1f6ebfa59634eea8e2c9b2f3f5eb
/frameworks/base/media/java/android/media/AudioService.java
f2b0c11f4e797e183131261724d8de310dac5431 09-Jul-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix sound effect attenuation calculation

The sound effect volume attenuation calculation is wrong: the
division by 20 was always returning 1 or 0.
In AudioService, rename the sound effect attenuation value to
follow the naming conventions for static variables.

Change-Id: I3c36d50f4470ff09ca98cb944aefb5ad0f968782
/frameworks/base/media/java/android/media/AudioService.java
c390bed06b4a572e273ead1254da9a932e04dce3 03-Jul-2012 Eric Laurent <elaurent@google.com> AudioService: fix a2dp force use delay

Fixed setBluetoothA2dpOnInt() so that AudioSystem.setForceUse()
is called synchronously and not via a message.

This is because the order in which setForceUse() and setDeviceConnectionState()
are executed is important to avoid audio glitches when called from
onSetWiredDeviceConnectionState().

Bug 6720482.

Change-Id: I09c975d1108fd38f31b047c082acdf944ab790a7
/frameworks/base/media/java/android/media/AudioService.java
f98de1e8dd6dcbd191921b4aa07a1d41b0b9db91 20-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Asynchronous handling of remote volume updates

Remote playback information updates will be posted from the
application thread, and sent to AudioService. Because they
require locking the stack containing the remote playback
information, the update should happen on AudioService's handler
thread to avoid lock contention.

Change-Id: Ie04898295e08c16dd8ab5985fd825301e9cf1981
/frameworks/base/media/java/android/media/AudioService.java
1357012968f9066ea3051d83995e9bac69526c3c 19-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Remote volume handling in MediaRouter

Extend MediaRouter.UserRouteInfo to enable setting playback
information, which includes volume. When the user route instance
has a RemoteControlClient, forward any playback information to it.
Enable specifying a callback to be notified of volume events
on the route.
Extend MediaRouter.RouteInfo to enable retrieving playback
information.

Update RemoteControlClient javadoc to reflect which parts of the
API are not intended to be made public.

Change-Id: I59d728eb61747af6c8c89d53f0faeb07940594c3
/frameworks/base/media/java/android/media/AudioService.java
2f4423043ffeaf232ec984be03743326f08cdc8a 19-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Merge "Remote volume handling" into jb-dev
dd0a19266d5c837069da1ea188744d54c8d723a8 19-Jun-2012 Adam Powell <adamp@google.com> MediaRouter bluetooth a2dp selection

Remove bluetooth permission check from internal AudioService method
setBluetoothA2dpOn

Manage BT A2DP state in MediaRouter. A2DP is only enabled or disabled
when either the system built-in audio route or the A2DP audio route is
selected; when selecting any other route the current state is left
alone.

Change-Id: Ib14274e206e79bd8762edca1205ecfa87b7a94cf
/frameworks/base/media/java/android/media/AudioService.java
3114ce3861f20f9a5c2c59dd2629197a1f4874a8 12-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Remote volume handling

Extend RemoteControlClient class to enable an applicaton to
specify more information about how it's playing media, now covering
usecases where media playback happens "remotely". This playback
information can be used to set the volume and maximum volume
used remotely.
Declare a new intent and associated extras in Intent,
ACTION_VOLUME_UPDATE, so an application can be notified that
the volume it handles should be updated. It can then use
the new RemoteControlClient.setPlaybackInformation() method
to notify AudioService what the volume is.
Extend AudioService to maintain playback information associated
with the RemoteControlClient information in the stack of
media button event receivers (mRCStack). The information
about the active remote is cached so the stack doesn't have
to be iterated over in order to retrieve remote playback info.
Events to "adjust" the remote volume based on hardware key
presses cause the client application to be notified of
volume updates, and the volume panel to display the volume
set by the app.
Revise which stream type is controlled when none is specified
according to latest guidelines for remote playback.
Update VolumePanel class to support a new pseudo stream type,
AudioService.STREAM_REMOTE_MUSIC, that corresponds to the
remote playback volume, and uses the new "media route" icon.
Enable it to receive asynchronously new volume values for
the remote that will be displayed if the UI is still up,
and ignored otherwise.
Now supports hiding/showing sliders dynamically so remote
volume only appears when AudioService has a remote control
client handling remote volume.
Define new java symbols for the two media route icons.
Modify lockscreen behavior: don't automatically control music
volume when music is active, consider also remote playback.

Still to do:
- playback information set by RemoteControlClient should post
a message for AudioService to update playback information
instead of updating it synchronously

Change-Id: I557aa687239f9acfe33a609f05876c67fa7eb967
/frameworks/base/media/java/android/media/AudioService.java
632ca417f0a33e3fa9ccece531afa2db3f0d4a30 15-Jun-2012 Dianne Hackborn <hackbod@google.com> Add new callback for MediaRouter to found out about device changes.

The AudioService now has an API to call to get the currently
connected devices, and later reports of changes in connection
state. The information includes the name of the bluetooth
device if one is connected for display to the user, and states
for all of the pluggable devices. No longer requires a Bluetooth
permission to keep the routes updated.

Change-Id: I81ca421c60592fbc1592477d59bf1c9d1b64954a
/frameworks/base/media/java/android/media/AudioService.java
6a5f9f6ddbfcb97a25436ad34be39fc7b3b45168 08-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Merge "Configuration for lock and UI sound levels" into jb-dev
e12c39bb9cedb8b363658979872694eb55b1386e 06-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Always queue A2DP connection state message with wakelock held

Messages for changes to A2DP connection state are intended to be
queued in AudioService after acquiring a wake lock, which is
released after the message has been handled.
This was correctly done for connection messages when the system
is up and running, but wasn't when the BluetoothProfile service
listener gets an onServiceConnected() event, which is the case
the the device boots.
This change correctly uses the queueMsgUnderWakeLock() method
whenever a MSG_SET_A2DP_CONNECTION_STATE is to be sent.

Bug 6616292

Change-Id: Ie337a4641a89c522e2d233bccaac4e08ce324117
/frameworks/base/media/java/android/media/AudioService.java
c55b393efd462490cd5e27fc373bceafdd25662e 05-Jun-2012 Jean-Michel Trivi <jmtrivi@google.com> Configuration for lock and UI sound levels

Define two integers in the platform configuration to
define the sound level for lock/unlock sounds, and
UI sound effects.
Use the corresponding value in KeyguardViewMediator for the lock sounds.
Use the corresponding value in AudioService when playing sound effects.

Bug 6448481

Change-Id: Ie238f5eb1645e395412864d93447ac4049f7e54b
/frameworks/base/media/java/android/media/AudioService.java
2d8dab5a549b25b6f36df4614d7c0166d4d099e2 31-May-2012 Jean-Michel Trivi <jmtrivi@google.com> Handle wakelocks for device connection intents from AudioService

Now that AudioService handles the device connection intents itself,
those need to be sent under wakelock.
The wake lock is acquired when AudioService is notified of the
device connection, and released when the corresponding message
has been handled.
This change only covers the device connection messages, and doesn't
affect the handling of the other AudioService messages.

Bug 6485897

Change-Id: I2d35f5404f097b5adde8af21fd81347bdd5576a6
/frameworks/base/media/java/android/media/AudioService.java
b1fbaaccb656ef09a8770c28df15e3e91a452e64 29-May-2012 Eric Laurent <elaurent@google.com> Send device connection intents from AudioService

AudioService is currently notified of wired headset and A2DP
sink connection states via broadcast intents from WiredAccessoryObserver
and BluetoothA2dpService. This is a problem as there is no guaranty that
AudioService can take actions upon the change before other apps are notified.
For instance, the Play On feature requires the UI to be refreshed when a device
is inserted/removed and we must guaranty that the UI component can read
new A2DP enable state from AudioManager after it receives a device connection state
change intent.

- Added hidden methods to AudioManager so that WiredAccessoryObserver
and BluetoothA2dpService can notify AudioService of device connection directly.
- The wired accessories connection intents are now sent by AudioService.
- The A2DP state change intent is delayed by BluetoothA2DPService when
ACTION_AUDIO_BECOMING_NOISY is sent by AudioService
- ACTION_AUDIO_BECOMING_NOISY intent is not sent when disconnecting A2DP
while a wired headset is present and vice versa.

Bug 6485897.

Change-Id: Ie160b3ee5f451132065530772b868593c90afd94
/frameworks/base/media/java/android/media/AudioService.java
7847211fb4699bf6018e29d214a918ed6657319b 21-May-2012 Eric Laurent <elaurent@google.com> AudioManager: restore setBluetoothA2dpOn() method

Remove deprecation on setBluetoothA2dpOn() method so that applications
can override the default audio policy which is to use A2DP
for media whenever connected.

The request is not persistent and the default policy is restored when a
new A2DP i ro wired headset connection occurs.

Bug 6485897.

Change-Id: I2a4b6b6bdba55f7b133e64f86d27c03eb86acfa4
/frameworks/base/media/java/android/media/AudioService.java
3c2711fc2853394324b044632b79ca67388df8f4 20-May-2012 Jean-Michel Trivi <jmtrivi@google.com> Type of search on headset key long press must depend on device state

When the user long presses on the headset key, the type of search
that will launched must depend on the state of the device. The
following logic is implemented:
- screen on and device unlocked: action is ACTION_WEB_SEARCH,
- device locked or screen off: action is ACTION_VOICE_SEARCH_HANDS_FREE
with EXTRA_SECURE set to true if the device is securely locked.

Bug 6518222

Change-Id: I318770346b8d83e44dfcd4154bcdb517ea7098b5
/frameworks/base/media/java/android/media/AudioService.java
ab624c2fd4f0fad6ba7f422a960942e5a7035cea 17-May-2012 Jeff Brown <jeffbrown@google.com> Use FLAG_LONG_PRESS for headset long press interactions.

Handle canceled key events correctly and don't synthesize
key events in that case.

Unfortunately, the state machine was confused by some sequences
of key events that it might receive from the input dispatcher
when new activities take focus during a long-press on the headset key.
The audio service may receive a cancel event intended for the old
window, followed by a repeated down and finally an up for the new window.
Simplified this down to just two booleans.

Bug: 6484717
Change-Id: I9587d0a5e282419ef4d7c17665940682aacea96a
/frameworks/base/media/java/android/media/AudioService.java
722b808662eb20fa91151f1e3aa05fd911d1d226 16-May-2012 Jean-Michel Trivi <jmtrivi@google.com> Handle media button events during phone calls and when ringing

Add functionality in AudioManager/AudioService to register a
media button receiver for telephony that, when registered, gets
priority for media button key events during a phone call or
when ringing.

Bug 6484717

Change-Id: I0835fc02cb24d06ca59af5a32c3ba0ae93e54442
/frameworks/base/media/java/android/media/AudioService.java
8c78752f2bf786ca3e6f45b9dc6955d3b4bba59c 14-May-2012 Eric Laurent <elaurent@google.com> Implement new volume display policy.

Whenever a stream type is muted, the progress bar in volume panel
is at 0.
If a stream is muted by ringer mode and does not control ringer mode,
the progress bar is disabled.
Pressing VOL- when in vibrate or silent mode resets the last audible
volume of ringtone stream (music strem on tablets) to 0.

VolumePanel implementation:
- Always prefer AudioManager APIs over AudioService APIs when available on both.
- Do not use AudioManager.shouldVibrate() (deprecated).

Change-Id: I57fcb19ada4e8d729b6b41d668496562ebe340c3
/frameworks/base/media/java/android/media/AudioService.java
2d97a70ff8bbac5ea807003d65b64e3b255e82bc 12-May-2012 Jean-Michel Trivi <jmtrivi@google.com> Merge "Start voice-based interactions from headsethook key" into jb-dev
4294b83927f51e5c115ebaafd2e185ba5de91436 01-May-2012 Jean-Michel Trivi <jmtrivi@google.com> Start voice-based interactions from headsethook key

Implement the interception of long-press on keys that
can be used to trigger voice-based interactions (here
only HEADSETHOOK) only if the long-press hasn't been
trapped by the foreground application:
- if the key is not one that is used for voice input, handle
the event as before.
- if the key press wasn't long enough, simulate a delayed
key press.
- if long press is detected, send
RecognizerIntent.ACTION_WEB_SEARCH. Long press duration
is set to 300ms (a typical key press is under 100ms).

Bug 3225090

Change-Id: I5b3adeb91d3c41ccd54d23fdb93d7eaec496eee7
/frameworks/base/media/java/android/media/AudioService.java
8d8176d41b8b8f08435e727f03e43e27a542dcc2 11-May-2012 Mike Lockwood <lockwood@google.com> Merge "AudioService: Fix problem handling USB audio disconnect" into jb-dev
9841818b9a0280abf59343c9e00a2976dbc084fa 11-May-2012 Mike Lockwood <lockwood@google.com> AudioService: Fix problem handling USB audio disconnect

Also broadcast ACTION_AUDIO_BECOMING_NOISY on USB audio disconnect

Change-Id: I46dfcc744df880066aea6bf651334a081c14af0f
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
244820185269991186d07068b92985624cede4a5 10-May-2012 Eric Laurent <elaurent@google.com> AudioService: fix various volume issues.

Fix various issues in adjustStreamVolume() related to stream type aliases
using different ranges.

Always Update last audible index on all streams sharing the same alias.

Add check on setRingerMode() to prevent setting mode to VIBRATE when no
vibrator is present.

Issue 6455831.

Change-Id: Id110e05d2f16e208e1e398922617bf31967b62db
/frameworks/base/media/java/android/media/AudioService.java
3172d5e3e7520a745fa37b71fc1c7bf244b57085 09-May-2012 Eric Laurent <elaurent@google.com> AudioService: synchronized access to volume index

Add synchronization to prevent concurrent accesses to
volume indexes HashMap in VolumeStreamState.

Use ConcurrentHashMap for VolumeStreamState mIndex and
mLastAudibleIndex.

Issue 6421841.

Change-Id: I6dee805a79aa5e2cd0ba4072014a2fcdda4ed507
/frameworks/base/media/java/android/media/AudioService.java
bffc3d1bd33eb2d8e00a9f8b6261d815db503311 08-May-2012 Eric Laurent <elaurent@google.com> Silent and Vibrate mode clean up

Clean up related to new Vibration policy.
The vibrate behavior is now only derived from:
- presence of a vibrator on the device
- current ringer mode selected: NORMAL, VIBRATE or SILENT
If no vibrator is present the ringer mode can only be NORMAL or SILENT.

The control of ringer mode via volume keys when volume keys control the "master"
stream type (RING on phones, MUSIC on tablets) is as follows:
If a vibrator is present:
VOL- and volume equals 1: NORMAL => VIBRATE
VOL- and volume equals 0 and not continuous press: VIBRATE => SILENT
VOL+ and in SILENT mode: SILENT => VIBRATE
VOL+ and in VIBRATE mode: VIBRATE => NORMAL, volume = 1
If no vibrator is present:
VOL- and volume equals 0 and not continuous press: NORMAL => SILENT
VOL+ and in SILENT mode: SILENT => NORMAL, volume = 0

VIBRATE_ON and VIBRATE_IN_SILENT settings are not stored/retreived any more.

AudioService checks and corrects ringer mode and stream volumes if necessary when reading from
DB at boot time.

Also:
Added dump for stream volumes in AudioService.
Added device names missing in AudioSystem for USB accessory and USB device.

Issue: 6036529
Issue: 6414950
Issue: 6448163

Change-Id: I77fb821ec63e4e566320cac2701b4ac466e86aef
/frameworks/base/media/java/android/media/AudioService.java
f26f01784e1c733c53cad3ed31918e73448ce369 26-Apr-2012 Jean-Michel Trivi <jmtrivi@google.com> Make AudioService aware of device orientation changes

If the "ro.audio.monitorOrientation" system property is
defined and true, monitor device configuration changes
and see if the device orientation changed. If it did,
set the "orientation" audio system parameter to one
of "landscape", "portrait", "square" or "undefined".
Set orientation when starting AudioService, and
when media server restarts.

Change-Id: Idce548f93abf3aab30149e5952daaa7051630232
/frameworks/base/media/java/android/media/AudioService.java
94affdd80e20c334dd5bfff170aee878992195ad 01-May-2012 Eric Laurent <elaurent@google.com> Merge "fix unmute from volume panel on tablets" into jb-dev
f740664cd808bebfc35ded46da6002bdc97a1a16 01-May-2012 Eric Laurent <elaurent@google.com> fix unmute from volume panel on tablets

Changing STREAM_MUSIC from volume panel on tablets should exit silent
mode as does changing STREAM_RING on phones.

Issue 5970208.

Change-Id: Ia8ed62033da07a5d4dfcfa84b0b47b27414bdd9a
/frameworks/base/media/java/android/media/AudioService.java
c68022258ebd3dd97a5079ba99f4f3cd12b223b0 30-Apr-2012 Jean-Michel Trivi <jmtrivi@google.com> Optimize how AudioService receives media button events

AudioService maintains a stack of registered media button event
receivers.
This change modifies the broadcasters of ACTION_MEDIA_BUTTON intents
let AudioService directly handle the corresponding key event instead
of trapping the intent sent by PhoneWindowManager, KeyguardViewBase
and PhoneFallbackEventHandler.
Because the key event may be sent through a PendingIntent,
AudioService now also implements the OnFinished interface to be
notified when the event was consumed so it can release the wake
lock held if it was held when the key event needed to be sent
(see where PassHeadsetKey was instanciated in PhoneWindowManager).

Change-Id: I2e8614df94af9d54edbf714ef443cc372d21827a
/frameworks/base/media/java/android/media/AudioService.java
098d580cc2bb6c0891c756a4e5230c6c6b0d2376 27-Apr-2012 Jeff Sharkey <jsharkey@android.com> Migrate ringtone playback to SystemUI.

Introduce IRingtonePlayer, which handles playback for both Ringtone
objects and Notifications. SystemUI now hosts this player, which it
registers with AudioService. It also keeps MediaPlayer instances
warm, and cleans them up after stop() or Binder death.

Move both Ringtone and NotificationManagerService to play back audio
through this new interface.

Bug: 6376128, 6350773
Change-Id: I1dcb86d16ee3c4f07cdb2248d33dcff4ead3609a
/frameworks/base/media/java/android/media/AudioService.java
f5d70fd2add31cdb2e4ca1e931b47db95fa4b3e0 27-Apr-2012 Jeff Sharkey <jsharkey@android.com> Merge "Protect system services with DUMP permission." into jb-dev
6d5176638c2189595cede38fb92c3e7e8700e221 24-Apr-2012 Eric Laurent <elaurent@google.com> system and UI sounds volume policy

Implement a more consistent policy for system and UI sounds (key clicks, lock/unlock,
camera shutter, DTMF, low battery...):
- All system sounds are played over STREAM_SYSTEM stream type.
- The STREAM_SYSTEM volume that was previously fixed now tracks the volume of a "master"
stream type. This "master" stream type is STREAM_RING for phones and STREAM_MUSIC for
tablets which corresponds to the stream whose volume is modified by default by the volume
keys.
- The STREAM_SYSTEM volume ranges from -24dB to -6dB (-24dB to -12dB over headphones) when the
"master" stream volume ranges from its min to its max.
- DTMF tones are played over STREAM_DTMF that tracks the "master" stream volume in the same
manner with the following exception: when in call, DTMF stream tracks STREAM_VOICE_CALL volume.
- Camera shutter sound is played over STREAM_SYSTEM_ENFORCED stream that tracks the "master"
stream volume except in countries where regulation enforces this sound. In this case
its volume is fixed and cannot be muted.
- Low battery sound is played over STREAM_SYSTEM and therefore has a tunable volume and is
heard while in call.

Issue 6344620.
Issue 6069229.
Issue 6213100.

Change-Id: I53a237878ead596e706c5dbbb1420e62cde32bd7
/frameworks/base/media/java/android/media/AudioService.java
eb4cc492c93ab9635dde78b958a834120412e72a 27-Apr-2012 Jeff Sharkey <jsharkey@android.com> Protect system services with DUMP permission.

Change-Id: I5e53859f8b8e5473e54eca43ebd7de841f1a05ff
/frameworks/base/media/java/android/media/AudioService.java
45c90cefd13a03b852bb4b8da4be218876cbbb32 25-Apr-2012 Eric Laurent <elaurent@google.com> Fix AudioManager.forceVolumeControlStream()

AudioManager.forceVolumeControlStream() is used by VolumePanel to temporarily force the
stream type which volume is controlled by volume keys.

Current implementation is not working if the VolumePanel is not executed by the same process
as the one receiving the volume key events.

Issue 6302421.

Change-Id: I2700587a027ffb962429b42083312cd92fe79215
/frameworks/base/media/java/android/media/AudioService.java
59f482764e346a5c5ac118ee1f7b24da645c2559 06-Apr-2012 Eric Laurent <elaurent@google.com> Added support for USB audio devices

Two types of USB audio devices are defined:
- USB audio device: the audio device in USB device mode while
the Android device is in USB host mode.
- USB audio accessory: the audio device in USB host mode while
the Android device is in USB device mode.

Renamed intents for analog and digital docks to avoid confusion:
- ACTION_USB_ANLG_HEADSET_PLUG to ACTION_ANALOG_AUDIO_DOCK_PLUG
- ACTION_USB_DGTL_HEADSET_PLUG to ACTION_DIGITAL_AUDIO_DOCK_PLUG

Factorized code in AudioService broadcast receiver.

Change-Id: I1b6d0257a9d68ecb9495c78c98bac8c67fec7891
/frameworks/base/media/java/android/media/AudioService.java
1c35d117f01b5a6f66b82c57eb29350f16694070 05-Apr-2012 Justin Koh <justinkoh@google.com> am db9b114b: Merge "Adds flag argument to setMasterMute." into ics-aah

* commit 'db9b114b2e1f9c2034c3cd6df00245b039d90c28':
Adds flag argument to setMasterMute.
0273af55cf68d54d26d154b44d105d40fed79701 05-Apr-2012 Justin Koh <justinkoh@google.com> Adds flag argument to setMasterMute.

Adds flag argument to setMasterMute. This allows third parties to edit it
without showing the UI, for example.

TESTED = runs on Tungsten.

Change-Id: Idfd99a2476e60059cd93c9dfe07d03a389c3f5f5
/frameworks/base/media/java/android/media/AudioService.java
75cf9e19a575c28c200c02c0ab6f83bb79f5c50d 05-Apr-2012 Justin Koh <justinkoh@google.com> Fix the build.

Change-Id: Ibe818df8f360837688f12533cf0ac22ef89a8439
/frameworks/base/media/java/android/media/AudioService.java
6a8096d7d56ce4c65318f283ef666993f3020745 04-Apr-2012 Justin Koh <justinkoh@google.com> resolved conflicts for merge of bff6a514 to master

Change-Id: I741d5ab8ed0ce25a27330ffb55ba210534d11c3d
57978ed86286a33d5b1a0fd000ca3406ba9d87b3 04-Apr-2012 Justin Koh <justinkoh@google.com> Persists the master mute volume setting.

Persists the master mute volume setting across reboots.

TESTED = runs on Tungsten.

Change-Id: I9628b9369ca528b22413f62a9e7d697bae61d8ac
/frameworks/base/media/java/android/media/AudioService.java
b5f2088c8ebc3d880dac2141df19a57053b7bae0 03-Apr-2012 Mike Lockwood <lockwood@google.com> Merge commit '7f71d01'
3e29718d34eba7c6c455fa6bb622856fe651876e 03-Apr-2012 Mike Lockwood <lockwood@google.com> Merge commit '830ad08'
3caba517253d1703fc29b50740c4567b932279fb 03-Apr-2012 Justin Koh <justinkoh@google.com> Broadcast mastervolume regardless of change.

Broadcast mastervolume intents regardless of whether the system changed the
volume. This fixes the bug where the volume LEDs stop getting updates.

TESTED = runs on Tungsten.

Change-Id: Id363da3f825934fd7785ed3d3e436f74e657b7e6
/frameworks/base/media/java/android/media/AudioService.java
45edba1b8b0377dfe70a4f2b0afb0f04dd8e1ee9 28-Mar-2012 RoboErik <epastern@google.com> b/6232528 Reduce volume persist delay to 500ms

Change-Id: I45c32da0a1089ce8bc865e12b51c069a6db28fd4
/frameworks/base/media/java/android/media/AudioService.java
6c798970ccb8759d1e613b57111daa8da0ab44c7 02-Mar-2012 Lei Zhang <rzhang@google.com> Add batch volume adjust support to adjustMasterVolume() in AudioManager and
AudioService.

Change-Id: I09b1dfc93f14ca836e1ba2a400c00caed01fd541
/frameworks/base/media/java/android/media/AudioService.java
24b082f87e96c00d5c17d60c735423900be40e70 24-Feb-2012 RoboErik <epastern@google.com> Fix Audio ramping code

The audio ramping was being ignored and we were always adjusting
by the same amount.

Change-Id: Id4a6587fd488132816ae26776c0f798782470b1d
/frameworks/base/media/java/android/media/AudioService.java
9ac8d0c445a3ccde40c05f0f3ad0ec4e8265d4c6 07-Mar-2012 Eric Laurent <elaurent@google.com> AudioService: fix system stream muted by restore

Releases prior ICS (included) would persist the stream volumes in the
database when muted by silent mode. If the DB was backed up while in
silent mode, stream volume was backed up at 0.
When restored on a new device, the volume was restored at 0 which was
a problem for SYSTEM stream because it would never be corrected as
this stream volume is fixed.

Added a check on valid volume values when reading settings from the DB
and correct the DB if this happens.

Change-Id: Ie3b98eb74e10413c22aab7568b83ac3ace5bfc07
/frameworks/base/media/java/android/media/AudioService.java
d674dd50b7caf57aa8c9e7e4bc75c92d5f576167 02-Mar-2012 Lei Zhang <rzhang@google.com> Add batch volume adjust support to adjustMasterVolume() in AudioManager and
AudioService.

Change-Id: I34382839622a5cc5f2a8768aed011e8224cadff9
/frameworks/base/media/java/android/media/AudioService.java
1918d4353cb05fdfc59bf6244f06c5bb25102b3f 24-Feb-2012 RoboErik <epastern@google.com> Fix Audio ramping code

The audio ramping was being ignored and we were always adjusting
by the same amount.

Change-Id: I1dc122e033c382f556844c5acadcfb698c8d2092
/frameworks/base/media/java/android/media/AudioService.java
98ad9b9d6fd34aad487933170f50b5519313df61 16-Feb-2012 Eric Laurent <elaurent@google.com> Fix music volume regression on tablets

A regression was introduced by the change enabling per device volume:
music volume will not be completely silenced even if volume is shown at 0.

The problem is that when media volume goes to zero, silent mode is entered and
AudioService sends one message per stream/per connected device to the audiosystem
handler to mute volume on each stream. As those messages were sent with the
SENDMSG_NOOP attribute, some of them where lost.

Change-Id: Ic665b1e9dcaf09506a4ec19bf3fe6997d4b071fd
/frameworks/base/media/java/android/media/AudioService.java
9760647dd0ee67e7c20f3e9d661d2006b1df0b54 09-Feb-2012 Mike Lockwood <lockwood@google.com> Add support for non-linear ramping of master volume adjustment

Bug: 5472584

Change-Id: I1227007d1563eca739fb78b6d9595febc04a3f03
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
1ce5b26d707e0086e09af3cd0428f1b441145261 02-Feb-2012 Jason Simmons <jsimmons@google.com> Only send master volume or mute updates if the settings have changed
/frameworks/base/media/java/android/media/AudioService.java
9063154a793b0ab38b3c5992cbaed046427b4a82 06-Jan-2012 Mike Lockwood <lockwood@google.com> Restore persisted master volume if the media server restarts

Bug: 5755071

Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
b7bd88a3b6d4a34f8dd59c41fb8ed55135840069 05-Jan-2012 Mike Lockwood <lockwood@google.com> Don't allow changing master volume when muted

Bug: 5793021

Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
5c55a051ad7d86a464fb91426f1ea3c0250e38b3 15-Dec-2011 Mike Lockwood <lockwood@google.com> Defer persisting master data to avoid excessive database writes

Bug: 5705192

Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
3194ea94348bce8e7ee9f803698d877f46f8279a 07-Dec-2011 Mike Lockwood <lockwood@google.com> Remove reference counting and client death notification for master mute

The use case for master mute is to toggle it on and off from a
KEYCODE_VOLUME_MUTE event, so this was unnecessary and prevented unmuting
in certain cases

Bug: 5724755

Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
0dc37cce9d564ae43883c8dc8672b9266b881e63 01-Dec-2011 Mike Lockwood <lockwood@google.com> AudioService: Send broadcasts when master volume and mute state change

Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
ce952c8e13c535bedde77bcdb94dfcc7508475aa 14-Nov-2011 Mike Lockwood <lockwood@android.com> AudioManager: Add support for master mute

Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
4767690f09ea3447b8c5c32fb28d27650aa18e00 08-Nov-2011 Mike Lockwood <lockwood@android.com> AudioManager: transparently convert volume settings for other streams to master volume if config_useMasterVolume is set.

This allows Music2 and other media apps to control master volume without changing their code

Bug: 5567694

Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
8dc1dabd254249b7ddb8743e88fdb96580ffc585 27-Oct-2011 Mike Lockwood <lockwood@android.com> VolumePanel: Add support for master volume

Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
8517e46f3d3c2ce11de09aa849a8533ffc1a2026 25-Oct-2011 Mike Lockwood <lockwood@android.com> Save and restore master volume in the settings provider

Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
cbdb49dc5e1b993a0bc5c68dbfb9486bfa0cd762 20-Oct-2011 Mike Lockwood <lockwood@android.com> Simple master volume support

Still needs integration with Settings (for persistence) and VolumePanel UI.

Change-Id: I9eca92c4b1ef2df2564411006a35753ab9618dce
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
0e8392e1dc1c023cb4d14a10778ae9cca44aac86 09-Feb-2012 Mike Lockwood <lockwood@google.com> Add support for non-linear ramping of master volume adjustment

Bug: 5472584

Change-Id: Id75f8835f6693ae3fcb7ca451ada01f22faba1aa
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
a477bab9c3aec3cd48b633c321dcefb0d7d3f400 02-Feb-2012 Jason Simmons <jsimmons@google.com> Only send master volume or mute updates if the settings have changed

Change-Id: If12ec3b7a4b4bf5165d7538013759f07a845d8c4
/frameworks/base/media/java/android/media/AudioService.java
30c918ce7fbe171944b28fc91b3f22b3d631872d 11-Nov-2011 Glenn Kasten <gkasten@google.com> Use final on new member variables

Use final for member fields initialized to a new and that are never modified.

Change-Id: I042352c7bc21879613e7a50b1205b6923f8083cf
/frameworks/base/media/java/android/media/AudioService.java
4dd3674e517051f130fef36d2eb201c68ff61094 24-Jan-2012 Jean-Michel Trivi <jmtrivi@google.com> Bug 5567648 disassociate audio mode and audio focus

Don't automatically change the audio focus when
the audio mode changes. This is best handled by the
applications that change the audio mode so they
can address their usecases as they please (for
instance to define the behavior when switching calls).
Replaced the implicit "mode to focus" behavior with
two methods to request and abandon audio focus. These
methods are only to be used by the framework, and maintain
the logic in AudioService to prevent other apps to request
audio focus during a call.
A susequent change will update com.android.internal.telephony.CallManager
to take advantage of these two methods.

Change-Id: If84ebd508e985083e8cac82ece44940c72b5c669
/frameworks/base/media/java/android/media/AudioService.java
9bc8358ddaa01c3490f9709991989633a6a3dd42 19-Nov-2011 Eric Laurent <elaurent@google.com> audio framework: manage stream volume per device

Improve volume management by keeping track of volume for each type
of device independently.
Volume for each stream (MUSIC, RINGTONE, VOICE_CALL...) is now maintained
per device.

The main changes are:
- AudioService now keeps tracks of stream volumes per device:
volume indexes are kept in a HashMap < device , index>.
active device is queried from policy manager when a volume change request
is received
initalization, mute and unmute happen on all device simultaneously
- Settings: suffixes is added to volume keys to store each device
volume independently.
- AudioSystem/AudioPolicyService/AudioPolicyInterface: added a device argument
to setStreamVolumeIndex() and getStreamVolumeIndex() to address each
device independently.
- AudioPolicyManagerBase: keep track of stream volumes for each device
and apply volume according to current device selection.

Change-Id: I61ef1c45caadca04d16363bca4140e0f81901b3f
/frameworks/base/media/java/android/media/AudioService.java
5c17a820f9e46e0756c11795b3e6f89105f2f539 30-Nov-2011 Glenn Kasten <gkasten@google.com> Audio Java doc comment typos and minor changes

Change-Id: Id6ea6dccb8054c9f05db9a9c045387ce813659e6
/frameworks/base/media/java/android/media/AudioService.java
13f94dc5bdea85608cb2f9bded4e390389d40c0c 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Fix race conditions related to ringer mode"
0b8afdac736fcbc0b2ef7f39264fe5077d88b996 06-Jan-2012 Mike Lockwood <lockwood@google.com> Restore persisted master volume if the media server restarts

Bug: 5755071

Change-Id: I6934276049b4a9d713bb4754aa3bb2cd3b898604
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
d10a663be6e7f88fe855a0a9266af85f5a07d146 05-Jan-2012 Mike Lockwood <lockwood@google.com> Don't allow changing master volume when muted

Bug: 5793021

Change-Id: If93a41c4e61f1bc730759e77ee5b5f8165025c42
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
afbb047c3945e9c2b7e9bc6b25098d5fb80bba4e 15-Dec-2011 Eric Laurent <elaurent@google.com> AudioService: simplified handler messages.

For historical reasons, messages to the AudioSystem
handler in AudioService have a complex identifier combining several information.
Messages for a particular stream contain the stream type as part of the message type.
This complexity is not needed as the stream messages also carry a reference to the
VolumeStreamState object which contains all necessary information, including the stream type.

Also grouped parameters of MSG_PERSIST_VOLUME message into a single bit field to make room for
further needs.

Change-Id: Ia27af626b3447541e8f9eaceba21389a824d88e2
/frameworks/base/media/java/android/media/AudioService.java
c239379c0ce19bf1cbd8aaea9faacbbffeccb984 16-Dec-2011 Mike Lockwood <lockwood@google.com> AudioService: remove logging from adjustMasterVolume that was left in by mistake

Change-Id: I75c430d2c50c4cab3b6207efab5a6f11aed728d2
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
f9113d311b33a14b324a02e3310185af582a7882 15-Dec-2011 Mike Lockwood <lockwood@google.com> Defer persisting master data to avoid excessive database writes

Bug: 5705192

Change-Id: I252bd72ff72ef4a40174d4597059e89691acb34f
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
b782e8d71e693984cc5236f1cf08e0c3c11a4050 13-Dec-2011 Joe Onorato <joeo@google.com> logging

Change-Id: I6fde5617365f479884937615e0d3f0f4ecc2dc14
/frameworks/base/media/java/android/media/AudioService.java
ba195ebc76f23b6679443724ab58c9dc9f2df884 13-Dec-2011 Glenn Kasten <gkasten@google.com> Fix race conditions related to ringer mode

Consistently protect all reads and writes of mRingerMode by mSettingsLock.

Change-Id: I72675ff9009880cc212616f0f79f809a28eb6bff
/frameworks/base/media/java/android/media/AudioService.java
a8f4e8359531a2bbfd0ff7db86676937fdf20a65 07-Dec-2011 Mike Lockwood <lockwood@google.com> Remove reference counting and client death notification for master mute

The use case for master mute is to toggle it on and off from a
KEYCODE_VOLUME_MUTE event, so this was unnecessary and prevented unmuting
in certain cases

Bug: 5724755

Change-Id: I041a112cd39e1c00dcae27e2266a95ce225e9b64
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
52cb1da2c6567be55274ef2d9035e29ae27a31aa 07-Dec-2011 Amith Yamasani <yamasani@google.com> am f3364080: Merge "New and improved silent mode on lockscreen." into ics-mr1

* commit 'f336408000c4be36045401fb4df89528249e7383':
New and improved silent mode on lockscreen.
9c316f3c6ac785fd27be97a119dfe8f1303a8ed4 07-Dec-2011 Amith Yamasani <yamasani@google.com> am d49ec62c: am f3364080: Merge "New and improved silent mode on lockscreen." into ics-mr1

* commit 'd49ec62cfb0469c39f2b5d79cbf2a6f69cceb7d7':
New and improved silent mode on lockscreen.
6243edd818b84adfbe712d5d233d6414b33653ac 06-Dec-2011 Amith Yamasani <yamasani@google.com> New and improved silent mode on lockscreen.

3-state item to toggle between Silent/Vibrate/Ringer in long-press power menu.
No volume dialog on lockscreen, unless Power menu is up.

Set VIBRATE_IN_SILENT=1 when upgrading device.

Change-Id: I097d216f96c4abdbd83420e0c477106951b3607d
/frameworks/base/media/java/android/media/AudioService.java
3309386a1b62095ab91b5efe4e8aa5dbd8ea5066 01-Dec-2011 Mike Lockwood <lockwood@google.com> AudioService: Send broadcasts when master volume and mute state change

Change-Id: I7eb5041f0c14f419317e29ea6fa7faa9159cf165
Signed-off-by: Mike Lockwood <lockwood@google.com>
/frameworks/base/media/java/android/media/AudioService.java
89972657bd7fdd9def17fe75e2529865b2369722 03-Dec-2011 Amith Yamasani <yamasani@google.com> am f8dad0b3: am afd01086: Merge "Further volume improvements." into ics-mr1

* commit 'f8dad0b37d9aa2476ef3ab84b9f4a7a9f4c960e4':
Further volume improvements.
54a796259055a633ec74afed0dce2327e5a86d51 02-Dec-2011 Amith Yamasani <yamasani@google.com> am afd01086: Merge "Further volume improvements." into ics-mr1

* commit 'afd01086795c7c1f6950a709180b2361625b8b6a':
Further volume improvements.
afd01086795c7c1f6950a709180b2361625b8b6a 02-Dec-2011 Amith Yamasani <yamasani@google.com> Merge "Further volume improvements." into ics-mr1
ee07e110d92005f9dbd317a23721d9b7c9a5ed37 02-Dec-2011 Eric Laurent <elaurent@google.com> am 6cfa9e6c: am 0d3a2e93: Merge "AudioService: strengthen A2DP device detection" into ics-mr1

* commit '6cfa9e6c507a721f647518569c89db9560056079':
AudioService: strengthen A2DP device detection
c1f069bb40f45b38684997fcfceb35be6e037665 02-Dec-2011 Eric Laurent <elaurent@google.com> am 0d3a2e93: Merge "AudioService: strengthen A2DP device detection" into ics-mr1

* commit '0d3a2e93394efa4729e5c29ff4515f9f2644b8c3':
AudioService: strengthen A2DP device detection
2ef6f1bb5603c2e221191117695725237f49a5d5 01-Dec-2011 Amith Yamasani <yamasani@google.com> Further volume improvements.

- Remove silent mode from Power menu
- Show volume dialog on lockscreen
- Allow beeps when adjusting volume in lockscreen

Bug: 5586083
Change-Id: I93052a8ec5004c784f20e04488af9382d495e711
/frameworks/base/media/java/android/media/AudioService.java
6bc7f2cd30b6bd90806942b0722e22daa2108493 30-Nov-2011 Eric Laurent <elaurent@google.com> AudioService: strengthen A2DP device detection

If the intent BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED is broadcast
before AudioService is started, The A2DP device connection is never detected
by the audio framework resulting in audio not being routed to A2DP unless the device
is rebooted or the A2DP headset reconnected.

Make sure that A2DP device connection state is sampled when
boot completed event is received.

Issue 5665159

Change-Id: I04d82020afc00af28c5ea0bb9879ed55bcc9b6f3
/frameworks/base/media/java/android/media/AudioService.java
47a0a8832f819b3b55c503aa787d615f036b7100 16-Nov-2011 Mike Lockwood <lockwood@android.com> Merge "AudioManager: Add support for master mute" into ics-aah
29270da5f7dee7e81b9d69446c7d2030aea6ff74 16-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 4978c1a5: am 0ddb0143: Merge "Fix 5623252 unlink to death of audio focus client early" into ics-mr1

* commit '4978c1a5b07782d622ca9e3eedd649a5927d226f':
Fix 5623252 unlink to death of audio focus client early
08b2d32628d6c6230493dfcfdeafa219248f2ee5 16-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 0ddb0143: Merge "Fix 5623252 unlink to death of audio focus client early" into ics-mr1

* commit '0ddb0143895b816d4ff5c174b346390e07f26556':
Fix 5623252 unlink to death of audio focus client early
e7edc868538e83152e7bc35c830fee0d629baefc 16-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5623252 unlink to death of audio focus client early

When removing an entry in the audio focus stack, don't wait for
this object's finalizer to unlink to the death of the associated
client, and unlink right away.
The FocusStackEntry.unlinkToDeath() method is made safe to call
by catching the exception it can throw inside its body.

Change-Id: Id347a933d72dcb41531adff2854fb00277032cc9
/frameworks/base/media/java/android/media/AudioService.java
eb80b31b5548650675c078ccfffc3091402a9382 15-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 87597d9c: am 538dc6ac: Merge "Fix 5615747 Don\'t leak remote control client death handlers" into ics-mr1

* commit '87597d9ce00691f05703f728c17548df2bbc9cc2':
Fix 5615747 Don't leak remote control client death handlers
cfbcd3bf21c8453e9afd7740fdb7fc272c362389 14-Nov-2011 Mike Lockwood <lockwood@android.com> AudioManager: Add support for master mute

Change-Id: I98e87d1e266e0523c4aacb23cc5c4b3fdc7a1eac
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
0dba46f9b295ad1ec1cbeda0fd28d90624028816 15-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 538dc6ac: Merge "Fix 5615747 Don\'t leak remote control client death handlers" into ics-mr1

* commit '538dc6acfd14ea59f0b294531f9417ca04ca621f':
Fix 5615747 Don't leak remote control client death handlers
a9509736c85c19fe4ad4ba97a0545f0422a3dfc1 15-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5615747 Don't leak remote control client death handlers

Whenever a remote control stack entry is GC'd or removed from
the stack, unlink its death handler.

Change-Id: Ia4ed6667351849fd388272591e24ffc16959beaf
/frameworks/base/media/java/android/media/AudioService.java
f1ec32db686586eddd023583e1c5978005c06d58 14-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 9d36a995: am 258576a8: Merge "Fix 5607938 AudioFocusDeathHandler leaks GREF" into ics-mr1

* commit '9d36a99582518ed1a7fb005382e0128479b43e18':
Fix 5607938 AudioFocusDeathHandler leaks GREF
09d936feb886502c5dd78497dc0c5fd578751a9d 14-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> am 258576a8: Merge "Fix 5607938 AudioFocusDeathHandler leaks GREF" into ics-mr1

* commit '258576a82c2293c3a988bf2dc6744fd8082421f9':
Fix 5607938 AudioFocusDeathHandler leaks GREF
527c44e8a455dd0fdef1aeb6d7d8f99bb0839295 14-Nov-2011 Glenn Kasten <gkasten@google.com> Merge "Don't check return value of new for being == null"
de1f065be109e1c313d8330c8e34210fedaac74e 12-Nov-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5607938 AudioFocusDeathHandler leaks GREF

The AudioFocus death handler was correctly updating the audio
focus stack when an audio focus client dies, but the death handler
was leaking GREF if unlinkToDeath() is not called.
The fix consists in making sure unlinkToDeath() is always called
by calling it in its finalizer.

Change-Id: I0c5343b4986ab582cadbf171fc53816952dc16f5
/frameworks/base/media/java/android/media/AudioService.java
62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e 07-Nov-2011 Glenn Kasten <gkasten@google.com> Don't check return value of new for being == null

new either succeeds or throws an exception

Change-Id: I1615e10c4f6730495c49e56b64714a00141ea8ff
/frameworks/base/media/java/android/media/AudioService.java
43f7bbdfbb26f9938e74558f2c1bf2260ec50fdf 10-Nov-2011 Eric Laurent <elaurent@google.com> am 7c61fa70: Merge "Fix problems in tablet silent mode." into ics-mr1

* commit '7c61fa70a50e15466f807dd194e530bc4fd3a96a':
Fix problems in tablet silent mode.
96a33d1caad2fab0bc28891cfbf553f4b050bf0b 08-Nov-2011 Eric Laurent <elaurent@google.com> Fix problems in tablet silent mode.

Do not enter silent mode when ALARM stream volume is changed
to 0 by volume down key: Only RING, NOTIFICATION and MUSIC
streams control silent mode.

Report correct volume (0) for NOTIFICATION stream when silent mode
is entered by changing NOTIFICATION stream volume to 0 with
volume down key.

Change-Id: I3e0816dfae40bc127cc30cca02cdca6ec19e30a4
/frameworks/base/media/java/android/media/AudioService.java
a2aa08e20cb4f1e302bb7ae05882cd1be8cfa0d2 08-Nov-2011 Mike Lockwood <lockwood@android.com> AudioManager: transparently convert volume settings for other streams to master volume if config_useMasterVolume is set.

This allows Music2 and other media apps to control master volume without changing their code

Bug: 5567694

Change-Id: I48b6260b193b22c395be5a31cd1d270b2929a91e
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
4528548a06224382ee4c9cb575c8b10ae9f02f1e 01-Nov-2011 Eric Laurent <elaurent@google.com> am cd84197a: am 6e91e5b6: Merge "Fix volume indication in vibrate mode." into ics-mr0

* commit 'cd84197ac1226432de2e13c8fd678a4c88511e0f':
Fix volume indication in vibrate mode.
8ca9a1cf350bde9a429b8a6fe7c673b964048a54 31-Oct-2011 Eric Laurent <elaurent@google.com> Fix volume indication in vibrate mode.

The latest change in silent/vibrate mode selection via volume keys
was such that ringtone volume was not showing 0 when entering vibrate mode
by continuous press on vol down.

Issue 5530217.

Change-Id: I9ba817648e5dca40e0d19f5f606d7763ae61b1c6
/frameworks/base/media/java/android/media/AudioService.java
92537e6ff21d4b20738fae851c2174ea568eb843 31-Oct-2011 Ed Heyl <ed@google.com> merged by hand (services/java/com/android/server/PowerManagerService.java needs to be reviewed)

Change-Id: I86d1111d86cd1646ebc8a88d58aa393089e9f928
c696a53d1fe4d61373c5dc64dd057d322da90c8f 29-Oct-2011 Amith Yamasani <yamasani@google.com> Bring back the old-style Ring/Vibrate/Silent states when using volume keys.

In order to completely mute the ringer (no vibrate), introduce an extra
state beyond mute, which mutes the vibrator as well, if it was enabled.

Bug: 5530217

Change-Id: Ib1f299ee6bbca56c1aa7e1100662591362d08307
/frameworks/base/media/java/android/media/AudioService.java
5020e7e2d37865da862846b97d9959e83244a35e 27-Oct-2011 Mike Lockwood <lockwood@android.com> VolumePanel: Add support for master volume

Change-Id: I3119eb2b7d3b5e7ce87f1660b50c10ab79c7bbdf
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
619f06444bc828c6cf5c3fa4f4a309c9497dab45 25-Oct-2011 Mike Lockwood <lockwood@android.com> Save and restore master volume in the settings provider

Change-Id: I135c48155c41735c870e3934469c47f05bd74973
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
dff25597a9a862143c69e70e6ed86790538c23c1 25-Oct-2011 Mike Lockwood <lockwood@android.com> Simple master volume support

Still needs integration with Settings (for persistence) and VolumePanel UI.

Change-Id: I9eca92c4b1ef2df2564411006a35753ab9618dce
Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
b024c30a80684ac08daef3137b7ba0d347fe3ce5 15-Oct-2011 Eric Laurent <elaurent@google.com> Fix issue 5462427: Volume should never be 0 ...

Make sure that ring or notification volume index
never reaches 0 unless in silent mode.
Conversely, enter silent mode when this volume is set to 0.

Change-Id: Iff5e5e972b607f4736e7a704b26b2dadb40074b0
/frameworks/base/media/java/android/media/AudioService.java
950e8cb40a6d826af4cc2eef9d3908c1b70486e6 13-Oct-2011 Eric Laurent <elaurent@google.com> Indicate screen off condition to audio framework.

Add a mechanism for AudioService to notify audio framework and audio HAL
that screen is turned on or off. This indication can be used by lower
audio layers to trigger low power audio playback mode.
Current implementaiton based on setParameters() method is experimental
and will be replaced by a different interface when ready.

Change-Id: Ie72ada0a8edec3d71b47681b9f51cb5bc839d45b
/frameworks/base/media/java/android/media/AudioService.java
7ff866e8cf43afc64111e98863dab549b57447b4 14-Oct-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5153611 remove remote control client/display log from AudioService

Do not log debug messages for the RemoteControlClient and
IRemoteControlDisplay related features.

Change-Id: I81bfeec1770f81b78b679dc03fb40806393b170a
/frameworks/base/media/java/android/media/AudioService.java
26b3d1ff38998c7cb80a2950da0589ebd8510897 28-Sep-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 5357295 NPE on display when remote control client dies

When a IRemoteControlClient dies, that client is set to null
in the stack of remote control entries (mRCStack). This is done
by calling registerRemoteControlClient() with a null client.
The bug is that registerRemoteControlClient(), after storing
the new client, uses it to let it know what the current
remote control display is. When that display is non null, the
client is sent the current display. So when a client died
when there was a display, the client reference was accessed
in the part of the method where we haven't yet checked whether
it is null or not.
The fix consists in moving the setting of the display on the
client (method plugRemoteControlDisplay) only after having
checked that the client is non-null.

Change-Id: Ic74d6cba9e3a3a16e78cd80a1ae5901abfeb3905
/frameworks/base/media/java/android/media/AudioService.java
f0cff0456258478ba768097f73d4367ab67fd7a3 15-Sep-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5300223 RemoteControlClient uses PendingIntent for media button events

Update the implementation of the RemoteControlClient / Display
feature rely on PendingIntent as provided in the construction
of the RemoteControlClient instance.
The ComponentName that describes the target of the media button
events is set as the target of the Intent from which
a PendingIntent is constructed.
This ComponentName is still saved in the stack for persisting
the last media button event receiver.

This CL also updates the lockscreen IRemoteControlDisplay
implementation to use the PendingIntent supplied by the
application when sending transport control events. A (good)
side effect of doing this is that intent will be directly
targeted at the application.

Restoration of the media button event receiver
after reboot is not fully functional yet.

Change-Id: I2be82f2839e9dee1de02512437b3fb41cc386cde
/frameworks/base/media/java/android/media/AudioService.java
d7454be47f4111c0478a502353e11dea401378bd 14-Sep-2011 Eric Laurent <elaurent@google.com> Issue 5044873: Pb with BT SCO AudioManager API

Do not identify the SCO connection client by the binder interface
passed when starting the connection as this binder changes if the
AudioManager proxy changes. Use the client PID instead.

This solves an issue with gTalk starting a SCO connection from one
AudioManager proxy and then changing audio mode from another thus
terminating the previously started SCO connection.

Change-Id: Ia3067fecc551fc15df3bf75ce0c43d181859e4f0
/frameworks/base/media/java/android/media/AudioService.java
9f103de83f2d5d472960dcf1401e95b2ab57a477 09-Sep-2011 Eric Laurent <elaurent@google.com> Fix issue 4673378: switching from VoIP to GSM call

The problem is that any app can change the audio mode and override
a mode previously set by another app. If two apps (gTalk and Phone) compete
for audio mode ownership, there is no mechanism to maintain coherency
in the actual audio mode selected.

Added a mechanism in AudioService to manage an audio mode request stack.
Any app requesting a mode different from NORMAL enters at the top of the stack
and the requested mode is applied. When an app sets mode back to NORMAL, it exits
the stack and the new mode corresponding to the request at the top of the
stack (if any) is applied.

Change-Id: I68d1755d0922f680df4a19bfc5ab924f5a5d8ccd
/frameworks/base/media/java/android/media/AudioService.java
671db6f3ba1fdb3c907e0735fe6d0d284f5c34de 07-Sep-2011 Marco Nelissen <marcone@google.com> Fix startBluetoothSco race

Change-Id: I8b711bd3c6b12f2e3e92144c0dadac72261bf914
/frameworks/base/media/java/android/media/AudioService.java
dca56b9432e2cc851d1a58920071fed2e1e3d142 02-Sep-2011 Eric Laurent <elaurent@google.com> Fix issue 5252593: any app can restart the runtime

Replace null device address string by empty sting.

Change-Id: I285c35f3345334e6d2190493b1a8a5aca1a361a4
/frameworks/base/media/java/android/media/AudioService.java
a6ec356d2f5d2829fd8eff315a37f49501eac842 01-Sep-2011 Jean-Michel Trivi <jmtrivi@google.com> Merge "Fix 5243349 RemoteControlDisplay incorrectly updated"
b716f0b7b2d8e4b045843fc6a7004910eb344c19 01-Sep-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5243349 RemoteControlDisplay incorrectly updated

This fixes a case where the RCD would display transport control
for a RemoteControlClient that didn't have audio focus.
This was happening because registering an RCD was directly calling
the updateRemoteControlDisplay method, without first calling
the checkUpdateRemoteControlDisplay method which verifies the
conditions before updating the display. One of those conditions
is that the audio focus stack shouldn't be empty.

To verify this fix, several functions were also rename to clearly
indicate the lock order and verify we properly synchronize on
the right objects. In doing so, a missing synchronization on
audio focus was found.

Change-Id: If1baaac224ea676aeb83ac0aefcc53f87461c32e
/frameworks/base/media/java/android/media/AudioService.java
16b241a58f1ec4b317647b6fd0ad9b5cc3f7ba3d 31-Aug-2011 Eric Laurent <elaurent@google.com> Merge "Change condition to enter silent mode."
338794576667745b060ac269b2c2b36e0c6964f2 31-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix 5242200 only update RemoteControlDisplay when a client is present

A precondition for updateRemoteControlDisplay_syncRcs() is that
mRCStack is not null. This condition was not verified when
registering a RemoteControlDisplay.

Change-Id: I0b152410e57c590114b387e9ab83f0c4d15d060d
/frameworks/base/media/java/android/media/AudioService.java
3d4c06f90726a85e89dab13c41ddc15b9c912a3f 16-Aug-2011 Eric Laurent <elaurent@google.com> Change condition to enter silent mode.

Previously, silent mode was entered if volume was already at 0 and
volume down key was pressed once.

The new volume management policy specifies that silent mode is entered when
volume is at last audible step and volume down key is pressed once.

Change-Id: Id3e75a99c522d8afe276868010b6e73495d23fde
/frameworks/base/media/java/android/media/AudioService.java
958bba6862c9540c528263686b0de044b4a7a5f6 30-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5045498 Force display update when display registers

When an IRemoteControlDisplay registers, cause the
RemoteControlClient to send all its information to the newly
registered display.
The previous code was only sending a request for update: this
request didn't here cause the client to send the data because
a new client generation had not been synchronized among clients
and displays.
This CL uses the same code path to force an update as when audio
focus changes, or a new client registers, by calling the same
method that is called in those cases,
updateRemoteControlDisplay_syncRcs(flags).
Also in this CL: more method renames to indicate methods that
are called synchronized on mRCStack.

Change-Id: I54102f45ba1cd4812d958ecd883bec7bc45ae88f
/frameworks/base/media/java/android/media/AudioService.java
db8a361629f06f62b9e1c40d4413b3b5099bd124 27-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Update IRemoteControlDisplay when it registers.

When an IRemoteControlDisplay registers, it must receive information
from the current client.

Change-Id: Id845e7a87ac74c2db2c59e0281b28a45f8d20528
/frameworks/base/media/java/android/media/AudioService.java
18e7bce52318f00b5023f33933a571c477f2b61c 26-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Address multiple RemoteControlDisplay competing for registration

The RemoteControlClient / Display feature only supports one
display. If multiple displays are registered, this CL implements
the following policy:
- cannot unregister a display that is not the current one,
- registering a display when another is already registered
causes the old one to be unregistered.
This fixes a death handler leak where the previous display was
simply overwritten, without unlinking to its death.

Change-Id: I63f8a38093796e0960761936d7fc58d47b7589b3
/frameworks/base/media/java/android/media/AudioService.java
3094d955b8321f01e50cb0c448ae1c4c461f41c9 25-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix deadlock in AudioService

Locks related to audio focus and remote control should always be
taken in the following order:
1/ audio focus lock
2/ remote control stack
3/ current remote control client generation

Change-Id: If8be11bfef92849957e692b2bd52adbd67a2ef0b
/frameworks/base/media/java/android/media/AudioService.java
4b6df6a3dcbd9990e36438c529fa8c16b2580df9 24-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> More information for RemoteControlDisplay about new client

When the client gets cleared, let the display know the new
client generation ID is for a clear.
When a new client becomes current, let the display know
what the associated media button event receiver is.

Change-Id: I18e37a309b5b30ed361a68918379b60418409f1e
/frameworks/base/media/java/android/media/AudioService.java
68e37ae87ad9932f2119c1b2fc361c1aed5841e4 23-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Merge "Bug 5045498 New implementation of remote control API"
4426e42ac6107bf6b09f7c4cdad39eb161d8b9ca 19-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5045498 New implementation of remote control API

Remote control displays expose an IRemoteControlDisplay interface
which they register through AudioManager.
Remote control clients create a RemoteControlClient object, which
implicitely exposes an IRemoteControlClient interface registered
in AudioService through AudioManager.
AudioService tells all clients and displays when a new client
is the one that should be displayed.
A client's data gets sent to the display when it is valid, or
it sets new data (while being valid).

The implementation for setting metadata and album art is temporary,
and will migrate to the MetadataEditor API in future CLs.

Change-Id: Ibab6ea1d94c68f32482c760c6ae269541f885548
/frameworks/base/media/java/android/media/AudioService.java
73a56fe47720cc2659da6fc0a01fcc28940e7243 23-Aug-2011 Eric Laurent <elaurent@google.com> Revert "Change condition to enter silent mode."

This reverts commit c11c3ae4dd5d4054e5b44a7bdfe6b203bdb69976.
/frameworks/base/media/java/android/media/AudioService.java
8c60d89b3704164d5a13e80ace6bea4b51af37a3 18-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Merge "Bug 5045498 RemoteControlClient interface"
8f6684144a617982763db3d2281e86f2a9d368db 17-Aug-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 5126270: Holding volume down vibrates"
cc11b1b8bb47aa6be23ff5c4caf683ff90074121 17-Aug-2011 Eric Laurent <elaurent@google.com> Fix issue 5126270: Holding volume down vibrates

Clear AudioManager.FLAG_VIBRATE in adjustStreamVolume() if
already in silent mode.

Change-Id: I8035a8cc713e1880799d9aaf053d8e4d12acad75
/frameworks/base/media/java/android/media/AudioService.java
178889eff7fa3361a5cb08d6d43846a1baf5216b 16-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5045498 RemoteControlClient interface

Define a RemoteControlClient interface that applications must
implement and register to be displayed on the lockscreen.

Change-Id: I67276ae653f203e76727432231f1d76535c31942
/frameworks/base/media/java/android/media/AudioService.java
c11c3ae4dd5d4054e5b44a7bdfe6b203bdb69976 16-Aug-2011 Eric Laurent <elaurent@google.com> Change condition to enter silent mode.

Previously, silent mode was entered if volume was already at 0 and
volume down key was pressed once.

The new volume management policy specifies that silent mode is entered when
volume is at last audible step and volume down key is pressed once.

Pressing volume down key continuously will decrease volume until
last audible step is reached, not 0.

Change-Id: Ib7b530668473d6a5af1e748f445d6185afed2158
/frameworks/base/media/java/android/media/AudioService.java
931e73946390b43fc08f5ae66770fba0efba5345 16-Aug-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 5131056: key beeps when screen is locked"
96f218e0b9834b959f1acf34b51d325bb1c33a0d 16-Aug-2011 Eric Laurent <elaurent@google.com> Fix issue 5131056: key beeps when screen is locked

Clear AudioManager.FLAG_PLAY_SOUND in AudioService adjustSuggestedStreamVolume()
if keyguard is locked.

Change-Id: I2effb9cab8d946845e948b28899b17d7f24c1282
/frameworks/base/media/java/android/media/AudioService.java
0a9faa8cf934ef38319cd945b600825c6bb88b9c 15-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5045498 Send media button event receiver to remote control

When notifying the remote controls of an update, also pass the
associated media button event receiver.

Change-Id: I9125378653ce21e3bd672b936df638c0c6154edb
/frameworks/base/media/java/android/media/AudioService.java
baf674eedd5ecff9da0cf8cabe9868f7699b1695 15-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Fail request for audio focus when linkToDeath fails

When requesting audio focus and linkToDeath() threw a
RemoteException, AudioService was only logging a warning, and
was still changing the focus, with a non-null death handler.
The change first check that linkToDeath() didn't fail, and only
then proceeds to change the focus (dispatch focus change
notification, updates the focus stack, and updates the remote
controls).

Change-Id: I0b96dd3c6e924d93f419880349d49f8b360b110b
/frameworks/base/media/java/android/media/AudioService.java
061214bb71a4a4211e670001226c68f5e8036b84 14-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix leak of global references and AudioFocusDeathHandler objects.

Need to call unlinkToDeath() for the object to be garbage collected.
Save the object in the FocusStackEntry, unlink to death when we remove it from the stack.
See http://b/issue?id=5048400

Change-Id: I84c5ba46017d0a8744b5e7509a7c7a5c8dd918fb
author: olivier@google.com
/frameworks/base/media/java/android/media/AudioService.java
b5f04d6dbf5106140df367ae07f0e7708e1b650e 10-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Pass flags on remote control client information change in intent

Pass the flags about what information changed in the remote
control client in the intent used by the remote control display.
Also pass the IRemoteControlClient to verify it is still current
before sending the intent.

Marked some logs as to be removed before release.

Change-Id: Ib3aa22d061e5dfaf80a9c4c78774c931a2cf0fbd
/frameworks/base/media/java/android/media/AudioService.java
f1ddd51f9cd2f92b922bc636c307210a8d587c25 10-Aug-2011 Marco Nelissen <marcone@google.com> Check pids instead of IBinders

There can be multiple AudioManagers per process (because each Context has
its own cache of services), so AudioService should protect SCO activation
based on whether the pids match, not whether the IBinders match.

b/5044873

Change-Id: Ibec81365f95fec11f34b47becd0e473762bf06ad
/frameworks/base/media/java/android/media/AudioService.java
17da769e987de40e113c5b2a3b867b25ba7ac0a2 10-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> AudioService: don't use a soft reference on IRemoteControlClient

In the remote control stack, don't use a SoftReference to the
IRemoteControlClient because the client live in a different
process, which causes the reference to become null at the
earliest opportunity.

Change-Id: I7f7733f9a1a043825cd5e8769282b535657dd82d
/frameworks/base/media/java/android/media/AudioService.java
8d4ed0d8e1e0e0f4a8ed7fc1407a850dc2190040 08-Aug-2011 Neel Parekh <neel@google.com> Prevent NPE when registering a remote control client

Change-Id: Ia22b456b1cbdd89736118c7e68b7c68dd6e59c64
/frameworks/base/media/java/android/media/AudioService.java
7b6198cacc3e7dd31ef91537d809857d826fb7fa 07-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 5045498 API for client to notify remote control info changed

Update to API for a client to notify what type of information
changed (e.g. playstate, metadata) to optimize small updates
without the remote control display having to do expensive
queries such as album art.

When the remote control display retrieves the flags about
what information changed, the flag gets cleared.

Change-Id: I7d3d8d3eecd1da44695d84905ed9e7b70fe38b86
/frameworks/base/media/java/android/media/AudioService.java
ced110ec5970c632f523dfc0350b6071461ea9bc 05-Aug-2011 Neel Parekh <neel@google.com> Make retrieving remote control client go through binder interface

The way the old way worked relied on the process retrieving the
current remote control client to be in the exact same process as
the AudioService. This removes that dependency.

Change-Id: I1ba8bf32b61ec1e979ef7eee9661ba801aa19690
/frameworks/base/media/java/android/media/AudioService.java
a30a21cf2ef37b490e3790aad3105cda115124d6 04-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Remove empty remote control client listener methods

Remove non-implemented methods for registering IRemoteControlClient
listeners.

Rename refreshRemoteControlDisplay() method to follow framework
conventions.

Change-Id: I9254e8eeea9020a530c9a32f328f0ef7dbd9dd0c
/frameworks/base/media/java/android/media/AudioService.java
045d179ff6568eaa30f66801e10fd888e2da0f9d 03-Aug-2011 Eric Laurent <elaurent@google.com> Merge "AudioService: ignore NOTIFICATIONS_USE_RING_VOLUME."
8f619182cb759718f64ab95fd6d61c16138f6952 22-Jul-2011 Jean-Michel Trivi <jmtrivi@google.com> Remote control display API and implementation

Extend the media button event registration AudioManager API to
enable applications to register as a client of "remote controls"
and let them provide information meant to be displayed
by the remotes.
AudioService sends a AudioManager.REMOTE_CONTROL_CLIENT_CHANGED
intent to let remote controls know when / from whom they can
retrieve the information to display.
Only application that own audio focus, are the currently
registered media button event receiver, and have registered
a remote control client, are eligible to appear on the
remote control.

To address in future CLs:
- change how a remote control client forces a refresh
- rename methods called under lock to ___Locked()
- make API public

Change-Id: Icca30ab05dac2605ee9246f8acb27a03dcea077a
/frameworks/base/media/java/android/media/AudioService.java
4eb5a5713877227374d7bac97719873b2c17e92a 03-Aug-2011 Eric Laurent <elaurent@google.com> AudioService: ignore NOTIFICATIONS_USE_RING_VOLUME.

Do not take NOTIFICATIONS_USE_RING_VOLUME setting into account now
that it has been deprecated. STREAM_NOTIFICATION and STREAM_RING
always use the same volume setting.

Change-Id: Ibf6e5f86133d3781fd9e66455be64582318d93e6
/frameworks/base/media/java/android/media/AudioService.java
5531a3a3cfce0fe0dd279cdce2de30cf777f5227 20-Jul-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 5012047: silent mode mutes music"
72668b2c040b581b298b069f3b5af5ed7f212d89 20-Jul-2011 Eric Laurent <elaurent@google.com> Fix issue 4499450: Unknown Ringer Mode

Added a validity check on ringer mode values in AudioManager.setRingerMode().

Change-Id: Ie780edc1d347009d90f000018a71520b04e0c4a1
/frameworks/base/media/java/android/media/AudioService.java
c1d4166289ce016965d1147f7e8d37862ee347ec 19-Jul-2011 Eric Laurent <elaurent@google.com> Fix issue 5012047: silent mode mutes music

Implemented different silent mode behaviors for tablets and phones.
The behavior inherited from Honeycomb was for tablets only and
was muting music in silent mode.

Change-Id: Ib053e7b70ca02190debc87648ab8a163f9d39577
/frameworks/base/media/java/android/media/AudioService.java
b06ac839dd2d0437fc8314f6deb7233af5af521e 26-May-2011 Eric Laurent <elaurent@google.com> Issue 4364098: bluetooth SCO not working

AudioService does not need to unconditionally stop virtual calls
when the audio mode is changed from normal. Only stop virtual calls
that have been started from AudioService.

Change-Id: I75992d3655661e5910536a62dc8a8e0256d835e8
/frameworks/base/media/java/android/media/AudioService.java
dc03c61fe3cd8d0805480e48a974986439977a60 01-Apr-2011 Eric Laurent <elaurent@google.com> Bluetooth SCO audio API improvements.

The AudioManager API to control bluetooth SCO did not provide an easy way for
applications to handle SCO connection errors. When a request to activate SCO with
AudioManager.startBluetoothSco() failed, no state change was indicated via
AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED intent. The application had to
implement a timeout to handle connection failures.

The API change consists in defining a new intent AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED
and deprecate AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED. The new intent
will broacast a new state CONNECTING when the SCO connection is initiated.
The application can monitor changes from CONNECTING to either CONNECTED or DISCONNECTED
states to detect connection success or failure.
An extra indicating the previous state is also added to the new intent.

Also improved BluetoothHeadset service management in AudioService. A disconnection
from the service is not considered as a device or SCO link disconnection. Instead, if the
service interface is not present when a request to activate SCO is received, an
attempt is made to reconnect to the service.

Change-Id: I005fda1caaf74bb7de64fece44e9c7e628e828db
/frameworks/base/media/java/android/media/AudioService.java
72843377d50a8f95cceaf33d316ab68d9b47f2eb 18-Apr-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2659754 ConcurrentModificationException in audio focus changes

While iterating over the audio focus stack or the media button
receiver stacks, do not modify the stack other than through the
iterator object.

Change-Id: Ice8827e7d29afed72b40c93edf7401cd54ba4b0c
/frameworks/base/media/java/android/media/AudioService.java
d589fea865e90859324f00d21765fa7d7759e465 15-Apr-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2724503 Persist media button receiver across reboots

Whenever a new media button receiver is registered, save it
in the settings.

When the system audio settings are reloaded or when the
AudioService is created, the registered media button receiver
is restored.

Whenever a package is removed from the system, remove
any media button receiver from the same package that are in
the media button receiver stack. If this causes the currently
registered receiver to change (i.e. the top of the stack),
this will cause an update of the receiver stored in the
system settings.

Note that unregistering a media button receiver will not
cause the receiver saved in the settings to be updated,
this is ON PURPOSE. This is to prevent well behaved
application who unregister their receiver at the destruction
of their service, to not receive the intent after a reboot,
and to not encourage applications to never unregister
their receiver.

Change-Id: I941b777debaa56e88de93c3b03aec40331ea9ab1
/frameworks/base/media/java/android/media/AudioService.java
fa640154f1f42121d81242b2f1a10f03e52f0014 13-Mar-2011 Eric Laurent <elaurent@google.com> Partial fix for issue 3515250: video chat and SCO

Do not call directly into AudioSystem in setBluetoothScoOn() but
send a message to the AudioService handler instead. As the
procedure to switch audio path to BT SCO can last some time we should
not block the caller which can run in the UI thread.

Change-Id: I6ac4b5a934d69781db3aebe5d0e8137b52a0ada4
/frameworks/base/media/java/android/media/AudioService.java
382f4e6ea4dcf39105b36364582ed01642daa93c 08-Mar-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 4064086 Use a death handler on audio focus changes from mode

Use a death handler when audio focus changes are caused by audio
mode changes.

The bug comes from the fact that audio focus clients that use the
audio mode for automatic focus handling didn't register a death
handler, which was set to null. When such a client died, this
handler was compared against the one to remove from the
audio focus stack, which resulted in an NPE.
The fix consists in registering a valid IBinder object in the
audio focus stack, even for clients whose focus requests originate
from a change in audio mode, as implemented in the
handleFocusForCalls() method.

Change-Id: Id9e1d3d10afcd99969285f6d60fc4d7dde1e4a10
/frameworks/base/media/java/android/media/AudioService.java
854938a72d968c1bc0de4e2b0ea87777cfebc045 22-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3388354.

Release all sco audio clients when the intent indicating
STATE_AUDIO_DISCONNECTED state is received.
Also clear mScoClients array when clients are released.

Change-Id: I63ec9d70fe72a102e09a4a473a367fb2e550b171
/frameworks/base/media/java/android/media/AudioService.java
a25c5d88d17f251262307ce31e799c9cf361d145 10-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3435692

The problem is that the AudioService is not notified of the death of
IAudioFlinger binder interface because no methods was called on AudioFlinger
from system_server since the device booted. Therefore, AudioSystem did not created any
IAudioFlinger interface in the system_server process.
The root cause was always present but more likely to happen on a tablet than on a phone
as for instance no beeps are played when volume is adjusted.

The fix consists in having AudioSystem explicitly call a method on AudioFlinger when a
callback is installed to make sure that an IAudioFlinger binder interface is created
regardless of any other activity in the client process.

Change-Id: I9df34a36825af0b25cd0246dd02edbd712263f41
/frameworks/base/media/java/android/media/AudioService.java
d4b88c8829cdababbf16aaf903ba25a1669310e7 05-Feb-2011 Eric Laurent <elaurent@google.com> Merge "Issue 3395734: fix media server restart detection" into honeycomb
086396a92408b47ee32f7fedaae9af533608ff6d 05-Feb-2011 Eric Laurent <elaurent@google.com> Issue 3395734: fix media server restart detection

Commit 25101b0b in AudioSystem for issue 3395734 broke the mechanism
in AudioService to poll and detect the restarting of media server
process after a crash.

The fix consists in changing the method used to poll AudioSystem and
trigger a callback indicating success when media server is responding
(the method must be on IAudioFlinger and not IAudioService to trigger the callback).

Change-Id: I843c0194de9cbf82c779cabbf2f3cbf8064603c8
/frameworks/base/media/java/android/media/AudioService.java
402f7f29634a9f68e7929be828a927a3e2f5efe9 04-Feb-2011 Eric Laurent <elaurent@google.com> Fix issues 3425035 and 3423785.

- Make sure that STREAM_MUSIC is affected by ringer mode on non voice capable
devices whatever the saved settings say.

- Added a hidden method to AudioManager for VolumePanel to override
the stream selection logic while the panel is showing.

Change-Id: Ib2ff2a7af63decb4e29c45700c41e5058f79d877
/frameworks/base/media/java/android/media/AudioService.java
25101b0b9a84571ead15b26e9f4cd9c4298d7823 02-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3371080

Modified default volume control logic in AudioService:
1 IN_CALL volume if in video/audio chat
2 NOTIFICATION if notification is playing or was playing less than 5s ago.
3 MUSIC

Modified silent mode:
- now also affect MUSIC stream type
- entering silent mode when VOL- hard key is pressed once while selected
stream volume is already at 0 (except for VOICE_CALL stream).
- exiting silent mode when pressing VOL+ hard key while in silent mode

Play sound FX (audible selections, keyboard clicks) at a fixed volume.

Modified audio framework:
- isStreamActive() method now implemented in AudioPolicyManagerBase (previously AudioFlinger)
- iStreamActive() now specifies a time window during which the stream is considered
active after it actually stopped.

Change-Id: I7e5a0724099450b9fc90825224180ac97322785f
/frameworks/base/media/java/android/media/AudioService.java
834662d4224ebbb95527cb43eaf9dcea548d7b19 28-Jan-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 3395289 Use MODE_IN_COMMUNICATION to evaluate stream vol changes

When the user is in a phone or VoIP call, the volume keys should
control the STREAM_VOICE_CALL volume. Before MODE_IN_COMMUNICATION
was introduced to cover VoIP use cases, having an active VoIP call
was determined by checking whether there was any track used the
output stream STREAM_VOICE_CALL, which can give false positives.
This CL checks instead against the audio mode to see if
MODE_IN_COMMUNICATION is selected to determine if a VoIP call
is in progress.

This implies that applications that play on STREAM_VOICE_CALL
shouldn't rely on that fact alone to expect the volume keys
to control the STREAM_VOICE_CALL volume, and should instead,
rely on the official mechanism for that:
android.app.Activity.setVolumeControlStream(int)

Change-Id: Ia487951ea1684477aa3d522c9031fad484d8a40d
/frameworks/base/media/java/android/media/AudioService.java
dde68c64fd8e97a592633ec4c09283ec928e5697 24-Jan-2011 Jaikumar Ganesh <jaikumar@google.com> Rename virtual call API to ScoUsingVirtualCall.

This API makes more sense with regard to headset profile.
Bug: 3381532

Change-Id: Ife07d101a3b04bcddb31e7ae86712e1d97a660c5
/frameworks/base/media/java/android/media/AudioService.java
117b7bb5b5a4457711f59bde3dcc83d8f111c524 17-Jan-2011 Eric Laurent <elaurent@google.com> Fix issue 3354692.

The problem is that SoundPool never calls the onLoadComplete() callback
when load() method fails because the file cannot be opened.
AudioService loadSoundEffects() was blocked waiting for a callback
that never came.
In this particular case, this happened on a specific build where sound
effects assets were not included.

The fix consists in waiting for the callback only if at least one sample is
accepted by SoundPool load().

Also moved the initial loading of sound effect samples from the boot completed
broadcast receiver to the audio service message handler to avoid waiting in the
main system server thread.

Change-Id: I902e5988f8b644a81d8e585c52eed1df4ca0ec05
/frameworks/base/media/java/android/media/AudioService.java
a60e212d0dda7d2a748180ce77405f2463c9cf53 29-Dec-2010 Eric Laurent <elaurent@google.com> Fix issue 3261656.

The problem can occur if a sample is started at the same time as the last AudioTrack callback
for a playing sample is called. At this time, allocateChannel() can be called concurrently with moveToFront()
which can cause an entry in mChannels being used by moveToFront() to be erased temporarily by allocateChannel().

The fix consists in making sure that the SoundPool mutex is held whenever play(), stop() or done() are called.

In addition, other potential weaknesses have been removed by making sure that the channel mutex is held while
starting, stopping and processing the AudioTrack call back.

To that purpose, a mechanism similar to the channel restart method is implemented to avoid stopping channels
from the AudioTrack call back but do it from the restart thread instead.

The sound effects SounPool management in AudioService has also been improved to make sure that the samples have
been loaded when a playback request is received and also to immediately release the SoundPool when the effects are
unloaded without waiting for the GC to occur.
The SoundPool.java class was modified to allow the use of a looper attached to the thread in which the sample
loaded listener is running and not to the thread in which the SoundPool is created.

The maximum number of samples that can be loaded in a SoundPool lifetime as been increased from 255 to 65535.

Change-Id: I368a3bdfda4239f807f857c3e97b70f6b31b0af3
/frameworks/base/media/java/android/media/AudioService.java
c7fcba4b7bd3d78e7cfe975a3f8e4dde2f6738b7 06-Jan-2011 Joe Onorato <joeo@google.com> Make the volume keys adjust the media volume by default if the device is not "voice capable."

Change-Id: Ide396f8940a075c0b00b7c983c1769c1cc0f17bf
/frameworks/base/media/java/android/media/AudioService.java
2c61bee2b05a6f4cf06a0048b3c0a81f248a48cd 15-Dec-2010 Eric Laurent <elaurent@google.com> Change audio routing policy for HDMI

HDMI device should have a higher priority than analog dock audio but a lower priority
than wired headsets.
Also modified AudioService so that HDMI is mapped to DEVICE_OUT_AUX_DIGITAL device and not
DEVICE_OUT_DGTL_DOCK_HEADSET as before to enable discrimination between SPDIF going to
digital dock and SPIDF going to HDMI.

Change-Id: I887d0c73479784dd2edaf41ce1a7d8d0bdcbb4bd
/frameworks/base/media/java/android/media/AudioService.java
2ade576148fe33c5ff6098d30ccfbcf28df70e8e 11-Dec-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 3275151 Request and abandon audio focus with audio mode changes

Before the introduction of the MODE_IN_COMMUNICATION audio mode,
"calls" were only made through telephony and the PhoneStateListener
was used to request and abandon audio focus as calls where started
and ended. VoIP applications do not cause phone state events to
be broadcast, and set the audio mode to MODE_IN_COMMUNICATION
directly. This change monitors mode changes to automatically
grab and abandon audio focus.

Change-Id: Ie9a4193e35ba8447764fac66a988959a93c4909f
/frameworks/base/media/java/android/media/AudioService.java
62ef767b15a712bab31cc0d5508a330906f535c2 24-Nov-2010 Eric Laurent <elaurent@google.com> Fix issue 3159946.

AudioService now uses SCO virtual calls instead of voice recognition to
implement startBluetoothSco() method.
Also make sure that a virtual call is not started when SCO audio is active
due to in call audio or voice recognition.

Change-Id: I93ed119afbc57250a4433201156714e35f70fea4
/frameworks/base/media/java/android/media/AudioService.java
8f677d66d9c3ba34c97e69b2bb9e161f129af0ee 15-Nov-2010 Jean-Michel Trivi <jmtrivi@google.com> Add new audio mode for audio communications other than telelphony.

The audio mode MODE_IN_CALL signals the system the device a phone
call is currently underway. There was no way for audio video
chat or VoIP applications to signal a call is underway, but not
using the telephony resources. This change introduces a new mode
to address this. Changes in other parts of the system (java
and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
state variable directly, but to use two new convenience methods,
isInCall() and isStateInCall(int) instead.

Change-Id: Id744cd26520ea1d1a4795eabe6a1f0c58789af76
/frameworks/base/media/java/android/media/AudioService.java
26e37349831476d3225570af2dfbf1e459374c6b 03-Nov-2010 Praveen Bharathi <pbharathi@motorola.com> frameworks/base: switch audio to hdmi when cable is plugged in

Change-Id: I01c4ee968bc0ffbb6ce75370935571cc1ff6f8c7
Signed-off-by: Iliyan Malchev <malchev@google.com>
/frameworks/base/media/java/android/media/AudioService.java
30d181690e48b26cdfae3b144d23f1e16c75da37 01-Nov-2010 Jaikumar Ganesh <jaikumar@google.com> Add STATE_AUDIO_CONNECTING state.

Why is it needed: SCO audio connections can fail.
Currently no indication is given to clients which are waiting
for SCO connections. This was working fine before because
SCO connections where blocking calls, which was wrong in itself.

Change-Id: Ic449b2db8506a7a5ae6be6c68715f1a7343f9e40
/frameworks/base/media/java/android/media/AudioService.java
21e941bf43362ddc6639a9f2d0828053360f53d7 06-Oct-2010 Praveen Bharathi <pbharathi@motorola.com> Added support for dock headset observer

Change-Id: I06b2e65e3bfa10735e6c7fd3349afa9ae7d45292
Signed-off-by: Praveen Bharathi <pbharathi@motorola.com>
/frameworks/base/media/java/android/media/AudioService.java
5a1e4cf83f5be1b5d79e2643fa791aa269b6a4bc 19-Oct-2010 Jaikumar Ganesh <jaikumar@google.com> Update BT APIs return type from Set to List.

Change-Id: Ia27220dd26cde13007f6938c830517ee7f6968ce
/frameworks/base/media/java/android/media/AudioService.java
82aa7f017daaaeb96c13e6e3491d5037ab471085 28-Sep-2010 Jaikumar Ganesh <jaikumar@google.com> Update code for new BT APIs.

Change-Id: Idf806cba8160e6075e33e26ee9936663b850e96c
/frameworks/base/media/java/android/media/AudioService.java
e73131a68408a0495ba96a4d5a60799ba293c176 14-Jun-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2684341 Don't steal the media button event from the phone
app is the phone is ringing, even in silent mode.

Use the PhoneStateListener to know whether the phone is ringing,
as the mode is not MODE_RINGTONE when ringing in silent mode.

Change-Id: Iede350cecde0b663d50f9b4a57f9a9ef08066c0d
/frameworks/base/media/java/android/media/AudioService.java
e2dd8c4592762414c2c27e4589be7edc91a5ecae 01-Jul-2010 Eric Laurent <elaurent@google.com> Fix issue 2811538: System server crash when disconnecting BT headset after using SCO off call.

Problem:
When the bluetooth device is removed, the AudioService clears all active SCO connections
and unlinks from the client application's binder interface death.
The problem is that the unlinking is done even if no more connections are active for a given client,
which throws a runtime exception that is not catched causing the system server to crash.

The fix consists in calling unlinkToDeath() in ScoClient.clearCount() only if the number of
active SCO connections for this client is not 0. The NoSuchElementException exception is also
catched when calling unlinkToDeath()

Change-Id: I29a28fcce1a579217cea271956a55778e05d3e37
/frameworks/base/media/java/android/media/AudioService.java
3c652ca5a546e7227a5f4bdbf0f81552b2c91383 22-Jun-2010 Eric Laurent <elaurent@google.com> Fix issue 2301630: Mismatch of state occurs when media server is killed while in-call.

Use setParameters() API to indicate to audio HAL that we are restarting the media server after a crash.
The use made by audio HAL implementation of this indication is platform specific.

Change-Id: I085b174fa1474575da0e4d295921079b6b68efb8
/frameworks/base/media/java/android/media/AudioService.java
740e39be6af3e366a4b82c030b5ea67ab144b42a 02-Jun-2010 Jaikumar Ganesh <jaikumar@google.com> Pass BluetoothDevice to the Bluetooth Headset calls.

This is to support multiple headsets at the same time, atleast
at the framework level.

Change-Id: I91d05c6c2828c9a09d00806d5e79f1e9c9c7cf84
/frameworks/base/media/java/android/media/AudioService.java
392a2bbb52688ebd25768a7784d9edca7f498110 11-May-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2670395 and 2599698
When the user selects a "Silent" notification sound, the Uri encoded
path is an empty string. Setting this Uri as the data source of the
MediaPlayer used to play notifications caused the completion listener
to not be called, which with the AudioFocus logic causes the Music
app to pause and never resume. The NotificationPlayer modifications
cause the MediaPlayer for the notification to only request audio
focus when the data source is not empty.
The audio focus code in AudioService is defensively synchronized
against a unique lock, and the exception observed in bug 2670395
is explicitely caught in case another edge case wasn't caught by
this fix.
The AudioFocus handling in AudioManager is modified so only the
requestAudioFocus and abandonAudioFocus methods are meant to be
used, as registerAudioFocusListener and unregisterAudioFocusListener
provided no additional functionality over the request/abandon
methods. abandonAudioFocus() also removes the listener from the
map in AudioManager since after abandonning focus, the listener
would no longer be called.

Change-Id: I3b553ee8a8163c25e01117d7e5479dd5fdfa7c6b
/frameworks/base/media/java/android/media/AudioService.java
a847ba4080675d395de725cfac5dfd9d5a993d4e 23-Apr-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2619062 Music is routed to Phone speaker, though it is
connected to A2DP media profile

When the phone is docked and using the dock A2DP, and the user
connects another A2DP device, make the dock unavailable immediately
before connecting the new A2DP device.

Change-Id: I82d53836fb509ee4ea7cdb68f467dfb946c634f8
/frameworks/base/media/java/android/media/AudioService.java
b4bccb6d8df16a2c5235cead187156bc721cf074 20-Apr-2010 Jean-Michel Trivi <jmtrivi@google.com> Update AudioService to reflect phone state changes with AudioFocus.
Phone calls and rings are treated as a new client, with a dedicated
client ID that identifies it in the audio focus stack. When it is
present in the stack, others clients cannot request audio focus
(request is denied).
Because the phone state is now mostly handled like a new client,
there is no need monitor mode changes and to keep track of
undispatched focus changes, as those will delayed focus gains
will now automatically happen at the end of the call when the
phone client is removed from the focus stack.

Change-Id: I11ff73b015ab93f07040755fd8ee75c8d675e025
/frameworks/base/media/java/android/media/AudioService.java
3891c4cc918e8062abb97c542a8625d556dccc59 20-Apr-2010 Eric Laurent <elaurent@google.com> Fix issue 2602879: camera shutter sound not playing.

The problem occurs if the device is powered down in silent mode. When the device restarts,
AudioService reads current ringer mode from saved settings but does not call setRingerModeInt()
to perform actions required when ringer mode changes.
The volumes of streams affected by ringer mode are actually at 0 because they are also read from settings
but their mute state is not applied correclty. When we later exit from silent mode, the streams
other than STREAM_RING that are affected by ringer mode are not restored as they are not considered
muted. This applies to STREAM_SYSTEM but also to STREAM_NOTIFICATION if its volume is controlled independently
from STREAM_RING.

The fix consists in calling setRingerModeInt() when AudioService starts.

Change-Id: Ica75b9874938dda1bc1b634c3e97db4a650d295c
/frameworks/base/media/java/android/media/AudioService.java
3b5912602bec6ccbe8eef8a576730b1565f0067c 20-Apr-2010 Eric Laurent <elaurent@google.com> Fix issue 2604270 Device auto connects to Car Dock (Media profile) after undocking.

There was a regression introduced by change 4c637b9e34f4c8db69a64ad21a4e2bcfa7485b5f
fixing issue 2578813. As the A2DP device disconnection is notified to the audio policy manager
after a delay, there is a period during which the A2DP device is actually not connected but the
A2DP output is considered present by audio framework. If a playback is started during this period,
The A2DP output requests the activation of the A2DP sink which in turn triggers a reconnection
of the A2DP sink.

The fix consists in suspending the A2DP output immediately when receiving the A2DP disconnection
intent so that any activity on A2DP output is ignored until the output is actually closed by the
audio policy manager.

Change-Id: I16eaace45e12bfc970f50836b46a73b756b493f0
/frameworks/base/media/java/android/media/AudioService.java
758dd527f64f1e827adfe09f0141ab213733ca22 13-Apr-2010 Eric Laurent <elaurent@google.com> Fix issue 2592680: Saved ringer volume forced to 0 when receiving a call in silent mode.

This is a regression introduced by change 5b4e654d0c7de8e4d58d73e73b0d5220f19b68f7 for issue 2472495.
When AudioService changes audio mode, setMode() reapplies current volume for the default active stream
which in this case is STREAM_RING.
Because the new implementation of silent mode actually mutes the ringer stream,
setStreamVolumeInt() now applies the volume change received while in silent mode
to the last audible value and we end up clearing the last audible volume for ringer.

The fix consists in not modifying last audible value when the new value is 0.

Also removed obsolete code in setStreamVolumeInt() since new implementation of setRingerModeInt()
in change 5b4e654d0c7de8e4d58d73e73b0d5220f19b68f7.

Change-Id: I746f3bc1af39a602ce12d130ce592007b2d0ebb6
/frameworks/base/media/java/android/media/AudioService.java
527c3ab51e258dfa15c6240f701693cf914e8e93 13-Apr-2010 Eric Laurent <elaurent@google.com> Fix issue 2589563: Able to set ringer volume to 0 outside of silent mode.

The problem happens only if volume down key is pressed while
already in silent or vibrate mode. In this case, AudioService accepts
changing the last audible index for ringer volume from 1 to 0.
When volume up is pressed, current ringer volume value is restored from 0
instead of 1.

The fix consists in keeping last audible index at 1 once in silent of vibrate
mode even is volume down key is pressed.

Change-Id: Id08edd12ce985c22233124545eba2c3e4b8cdc8e
/frameworks/base/media/java/android/media/AudioService.java
4c637b9e34f4c8db69a64ad21a4e2bcfa7485b5f 13-Apr-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2578813 Delay pausing music and routing audio for car docks

Moved broadcast of ACTION_AUDIO_BECOMING_NOISY from BluetoothA2dpService
to AudioService.
Broadcast ACTION_AUDIO_BECOMING_NOISY when disconnecting an A2DP
device.
Disconnect from A2DP docks with a delay to handle transient
disconnections.
Cancel delayed A2DP disconnections when connecting to a dock as this
can be a reconnection after a transient disconnection.

Change-Id: I1ee9e99f3ffa20727af38a4c4c8711942894a696
/frameworks/base/media/java/android/media/AudioService.java
bcac496076ef6f439147e7a2be71e8a2b76ddede 12-Apr-2010 Daniel Sandler <dsandler@android.com> Honor the "Never vibrate" setting for incoming calls.

Bug: 2579295
Change-Id: Ia4207492c5dfa2c39d27372c4892b60121b6d9e8
/frameworks/base/media/java/android/media/AudioService.java
2930bb2d47be279dd228ba8c749c1e39e5da8be1 10-Apr-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix monkey bug 2586534 java.util.ConcurrentModificationException
Unlike the other audio focus and media button stack handling
methods, abandonAudioFocus() and unregisterAudioFocusClient() were
not synchronized around their focus stack. This CL corrects this.

Change-Id: I5ada574e4e163fa95da9dad2fefe610b48303320
/frameworks/base/media/java/android/media/AudioService.java
55d1bb3483e17a11d122e68044e552d96ab55ff4 02-Apr-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2565463 Ensure an object cannot appear twice in the
AudioFocus stack.
Enforce parameter check in AudioManager.requestAudioFocus()
Typo correction in AudioService.unregisterMediaButtonEventReceiver()

Change-Id: Iedd6081a2a096bd7effbaeb9f888a31691201b3b
/frameworks/base/media/java/android/media/AudioService.java
5b4e654d0c7de8e4d58d73e73b0d5220f19b68f7 20-Mar-2010 Eric Laurent <elaurent@google.com> Fix issue 2472495: Phone cannot be set to silent mode via volume keys while Driveabout is taking.

The problem is that AudioService.adjustStreamVolume() only handles the ringer mode change when the
STREAM_RING volume changes from 1 to 0 or 0 to 1. If another stream is soloed, the STREAM_RING stream
volume is forced to 0 and then never transits from 0 to 0 when volume down key is pressed.

The fix consists in considering the saved value instead of current value when ajusting or setting
the volume of a muted stream: only the saved value is adjusted too, leaving the stream muted but updating
the value that will be restored when it will be unmuted.

Also changed implementation of stream volume control by setRingerModeInt() to use stream mute feature
instead of direct volume control.

Change-Id: Id85d76450b36d61a0fe8195eb4bffe63ffbd427c
/frameworks/base/media/java/android/media/AudioService.java
e5e1e870fdb35f5291790e6d178bde7126f6fe35 19-Mar-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix two AudioFocus issues:
- if a focus owner abandons audio focus during a call, the next
focus owner in the stack was never notified
- if a focus owner requests the focus while alread owning it, and
the type of focus request changes, the previous focus owner was
not notified that the type of focus loss had changed.

Change-Id: Iee6c6e17bcdd3c225a4b600f40ba434294870f17
/frameworks/base/media/java/android/media/AudioService.java
078fd47e91d495175927d1a4a8b9aad039a7ba4e 19-Mar-2010 Jean-Michel Trivi <jmtrivi@google.com> Support focus requests where ducking of the loser of audio focus
is acceptable for the new audio focus owner.

Change-Id: I965483f12eeb717115a8f6992d8f1ab7fafa4e45
/frameworks/base/media/java/android/media/AudioService.java
3def1eec2baed0b8845ec32c871e249dc533a9d9 18-Mar-2010 Eric Laurent <elaurent@google.com> Issue 2416481: Support Voice Dialer over BT SCO.

Added public methods to AudioManager API so that unbundled applications can use bluetooth
SCO audio when the phone is not incall.
Without this change, the only way to activate and use bluetooth SCO is via the BluetoothHeadset API
which is not public yet.

Change-Id: Ia1680f219ea1d0943092d475d5be7d6638983ebb
/frameworks/base/media/java/android/media/AudioService.java
d327f21626217aa3c9c0cdb7a84a742c531e59a3 17-Mar-2010 Jean-Michel Trivi <jmtrivi@google.com> Implementation of the policing of transport control key press
events among multiple applications competing for the remote control
focus.
AudioManager defines a new API for applications to use in order to
register their BroadcastReceiver for the media button as the one
to receive the corresponding intent, but all applications at the
same time (in an ordered broadcast).
AudioService handles a stack of remote control focus owners. It
traps ACTION_MEDIA_BUTTON intents and sends a new intent to the
remote control focus owner.

Change-Id: I3c109221ecfb160cbb1ec0e40a71b241aad73812
/frameworks/base/media/java/android/media/AudioService.java
758559e6b7e310cf46cc269437f44decd58d68d6 09-Mar-2010 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2329540
Part 1 of the fix: when the user doesn't elect to use the car dock
for music and media, the APM was not aware of the device being
docked.
This is fixed by dissociating the notification for the APM of
the docking to the dock from the sink state change of the A2DP
device.
Also missing was forcing the volumes to be reevaluated whenever
the device is docked or undocked, as volumes for docks may
differ, even when the same output device is being used.

Change-Id: If5314e27821a71adbd6df6fdf887c45208241d96
/frameworks/base/media/java/android/media/AudioService.java
31951ca52aa007891b0be975318199e207c70e02 03-Mar-2010 Eric Laurent <elaurent@google.com> Fix issue 2456968: Alarm rings in "silent mode and when Alarm in silent mode is turned off".

The problem is that even if silent mode is active, changing the alarm volume will change current
alarm stream volume. This is true for other stream types affected by ringer mode (ring, notification...) but
the UI design is such that it is not possible to change these volumes while in silent mode.

The fix consists in modifying AudioService.setStreamVolumeInt() so that when a stream is affected by ringer mode
and we are in silent mode, only the saved volume value is modified, current value remaining to unchanged (0).
/frameworks/base/media/java/android/media/AudioService.java
d5176cfe6eae954e9cef1e2ec17859a5089e1330 28-Jan-2010 Jean-Michel Trivi <jmtrivi@google.com> First implementation of the audio focus management as an extension
of AudioManager and AudioService.
/frameworks/base/media/java/android/media/AudioService.java
6329bf7b1e2217c6c9477bd57349a1edade18417 26-Feb-2010 Daniel Sandler <dsandler@google.com> New vibrate/silent mode behavior.

In earlier versions of Android, "vibrate mode" (in which
only alarms and media produce sound, but notifications may
operate the vibe motor) was only accessible by adjusting the
ringer volume (via the device's volume rocker) down until
the "vibrate" icon appeared (between the lowest ring volume
and silent mode).

Many users prefer that "silent mode" always allow vibration.
Others prefer Android's historical behavior, in which silent
mode stops the vibes as well.

To accommodate these two distinct usage patterns, we now
allow the user to decide whether vibration is allowed in
"silent mode", a user interface abstraction that now spans
both AudioManager.RINGER_MODE_VIBRATE and
AudioManager.RINGER_MODE_SILENT.

To minimize API impact (and therefore maximize backward
compatibility), RINGER_MODE_VIBRATE and RINGER_MODE_SILENT
remain unchanged. What has changed is what happens when the
user activates silent mode, either via Settings,
GlobalActions (longpress on power), volume rocker, or the
keyguard tab. In essence, there is now only one "silent"
position in these controls, and whether RINGER_MODE_VIBRATE
or RINGER_MODE_SILENT is actually set on the AudioService is
determined by a new one-off setting
(System.VIBRATE_IN_SILENT). This new setting isn't meant to
be a long-term API, however: in the future we hope to
replace and extend this design with a much more
sophisticated set of systemwide feedback profiles. ETA TBD.

Related changes:
* I09ad7d69 (GlobalActions and keyguard)
* I22ba7bcf (Settings app)

Bug: 2457183
Change-Id: I14cf91b0910261ffdfd1bf302423f41ec747d057
/frameworks/base/media/java/android/media/AudioService.java
9ce379aef155e0c21b5d82d8dc713c62792e4f30 16-Feb-2010 Eric Laurent <elaurent@google.com> Fix issue 2440226: Car dock volume synchronization.

AudioService now sends intent AudioManager.VOLUME_CHANGED_ACTION when the volume is changed
on any stream type (previously the intent was sent only for STREAM_BLUETOOTH_SCO stream).
A new extra for previous volume value is added to the intent.
/frameworks/base/media/java/android/media/AudioService.java
23f25cda0c73f8eb878844dea32fb0bd419edca2 25-Jan-2010 Eric Laurent <elaurent@google.com> Fix issue 2378022: AudioService should direct volume control to STREAM_VOICE_CALL stream when STREAM_VOICE_CALL stream is active.

Modified AudioService.getActiveStreamType() so that STREAM_VOICE_CALL is selected when a track using this stream
type is playing.

Chanded isMusicActive() for a more generic isStreamActive(stream) method in AudioSystem, IAudioFlinger and AudioFlinger.
/frameworks/base/media/java/android/media/AudioService.java
9272b4b4a44fe1f33e3030810618194f817caaec 24-Jan-2010 Eric Laurent <elaurent@google.com> Fix issue 2349345: Media sound output stuck on earpiece rather than speaker.

This change fixes a problem occuring when an application (for instance a VoIP application)
changes the audio mode to MODE_IN_CALL and crashes. In this case, the audio routing policy
remains as if we were in call until the audio mode is changed back to MODE_NORMAL, for instance when a new call
made or received and terminated.

The fix consists in registering a death receipient to the binder that made the setMode() request and resetting the audio
mode in case of client process crash.
/frameworks/base/media/java/android/media/AudioService.java
84b42b836845a921c853a3f8aa93227e1177f61d 09-Jan-2010 Eric Laurent <elaurent@google.com> am d31d7397: am 663ec308: Fix issue 2361949: A2DP suspend parameters set wrongly.

Merge commit 'd31d7397ba26dcd913e96d06f0a8fd593780d629'

* commit 'd31d7397ba26dcd913e96d06f0a8fd593780d629':
Fix issue 2361949: A2DP suspend parameters set wrongly.
663ec308801a34de82db9ab993f0e906da690f89 08-Jan-2010 Eric Laurent <elaurent@google.com> Fix issue 2361949: A2DP suspend parameters set wrongly.

Move reset of A2DP suspend state from handleSinkStateChange() in BluetoothA2dpService to
BluetoothA2dp.ACTION_SINK_STATE_CHANGED intent receiver in AudioService.
Previous implementation could cause a false reset of suspend state if a new sink attempted to
connect while A2DP was suspended.
New implementation only resets A2DP suspend state when a new sink is actually connected.
/frameworks/base/media/java/android/media/AudioService.java
a0b517609dfd8436a98bdebb31466f19ffec6cb5 28-Dec-2009 Eric Laurent <elaurent@google.com> am 68e9014e: am 484d2888: Fix issue 2299360: Change in in-call volume affects the Bluetooth in-call volume and vice versa.

Merge commit '68e9014e47f7350b3889e1704dde809b2a926968'

* commit '68e9014e47f7350b3889e1704dde809b2a926968':
Fix issue 2299360: Change in in-call volume affects the Bluetooth in-call volume and vice versa.
cf4fc6263c1c24ffa91a65a75edb126143a2617e 23-Dec-2009 Eric Laurent <elaurent@google.com> am f31f365a: am eb5ffc23: Merge change Id8e98194 into eclair

Merge commit 'f31f365a7708c931e955670bc6213fdc8f91a87a'

* commit 'f31f365a7708c931e955670bc6213fdc8f91a87a':
Fix issues 2333450 and 2333559:
eb14a783be073b5fd6e8c8c9bc87d2d1919f2c9e 17-Dec-2009 Eric Laurent <elaurent@google.com> Fix issues 2333450 and 2333559:

Add new config values to AudioSystem::FOR_DOCK force usage to differenciate car and desk docks.
Use a receiver for the sticky Intent.ACTION_DOCK_EVENT in AudioService to detect the type
of dock and select force usage accordingly.
/frameworks/base/media/java/android/media/AudioService.java
484d2888680e18e6ad8c3fcc51e3b70a705a096e 08-Dec-2009 Eric Laurent <elaurent@google.com> Fix issue 2299360: Change in in-call volume affects the Bluetooth in-call volume and vice versa.

Add a separate system settings entry for bluetooth SCO volume.
/frameworks/base/media/java/android/media/AudioService.java
1c633fc89bae9bf0af6fe643ac7ad2e744f27bed 09-Dec-2009 Dianne Hackborn <hackbod@google.com> Implement API to have new broadcasts replace existing broadcasts.

Use this in various places where it should serve no purpose to deliver
both broadcasts. This is intended to reduce somewhat the flurry of
broadcasts that we churn through during boot.
/frameworks/base/media/java/android/media/AudioService.java
6154412ee8e07e9cde129cccb944dd7ed9dcef53 08-Dec-2009 Jean-Michel Trivi <jmtrivi@google.com> Partially fix bug 2111240 Detect docking / undocking event by reporting
to the AudioPolicyManager a new forced usage AudioSystem::FOR_DOCK
which can take the FORCE_NONE, FORCE_BT_DOCK or FORCE_WIRED_ACCESSORY
values. This CL is complemented by an update of the APM to take into
account the FOR_DOCK usage.
/frameworks/base/media/java/android/media/AudioService.java
923d7d721d37f6ba5148e7d79d61a4fa48e79df2 12-Nov-2009 Eric Laurent <elaurent@google.com> Fix issue 2242614: Wired headset not recognized: bogus "state" in ACTION_HEADSET_PLUG broadcast.

The headset state indicated by HeadsetObserver in the broadcast intent ACTION_HEADSET_PLUG was not 0 or 1 as specified in the java doc but contained a bit field indicating the type of headset connected.

Modified HeadsetObserver to broacast a state conforming to java doc.
Added an extra to intent ACTION_HEADSET_PLUG to indicate if headset has a microphone or not.
Removed handling of non standard headset indications from HeadsetObserver.
Removed platform specific devices from output devices defined in AudioSystem.
Modified AudioService to use new ACTION_HEADSET_PLUG intent extra instead of bitfield in state.
/frameworks/base/media/java/android/media/AudioService.java
11a74a75653197a3d31fe91590cd8312f5270c44 28-Oct-2009 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 2201417. Whenever the System setting that indicates
whether the notifcation stream uses the ring volume changes, the
table of stream volume aliases in AudioService is updated. But the
name of the alias stored in VolumeStreamState.mVolumeIndexSettingName
was not updated whenever the NOTIFICATIONS_USE_RING_VOLUME setting
was updated. This caused the wrong volume setting to be persisted.
This change ensures the setting name is updated whenever the volume
alias is, and persists the notification volume change right away
(instead of after a delay), so that registered observers are notified
right away. The notification seekbar in the sound settings is an
example of such an observer.
/frameworks/base/media/java/android/media/AudioService.java
89e74ba1419732dd5c7f939e48d4aa7989fd3a51 01-Oct-2009 Eric Laurent <elaurent@google.com> Fix Issue 2158631: AudioService: volume control sometimes not restored after media server process crash.

The problem comes from the fact that the AudioSystem callback indicating that the media server is active again is ignored if it is received before the delayed message indicating media server death. This happens if another application or service running in the system server process makes a request to the AudioSystem in the interval between the death of the media server and the reception of the corresponding delayed message.

The fix consists in resetting mMediaServerOk flags immediately when the death callback is received and not when the delayed message is received.
/frameworks/base/media/java/android/media/AudioService.java
a2ef57dba9ac77d8eccacd646b2b8a8d99fe9d8b 28-Sep-2009 Eric Laurent <elaurent@google.com> Fix issue 2141503: Keyclick sound doesn't honor volume settings.

Use music stream volume minus 3 dB for sound effects if volume is not explicitly requested by application.
/frameworks/base/media/java/android/media/AudioService.java
005b228cdfb369d9b3b325884c0337ba5968bf8c 10-Sep-2009 Nick Pelly <npelly@google.com> API_CHANGE: Cleanup, javadoc and unhide more Bluetooth API.

This is a large batch, and covers:

-- Bluetooth Device Discovery --
BluetoothAdapter.ACTION_DISCOVERY_STARTED
BluetoothAdapter.ACTION_DISCOVERY_FINISHED
BluetoothAdapter.startDiscovery()
BluetoothAdapter.cancelDiscovery()
BluetoothAdapter.isDiscovering()

-- Bluetooth bonding (pairing) --
BluetoothAdapter.getBondedDevices()
BluetoothDevice.ACTION_BOND_STATE_CHANGED
BluetoothDevice.EXTRA_BOND_STATE
BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE
BluetoothDevice.BOND_NONE
BluetoothDevice.BOND_BONDING
BluetoothDevice.BOND_BONDED
BluetoothDevice.getBondState()
BluetoothDevice.createBond()
BluetoothDevice.cancelBondProcess()
BluetoothDevice.removeBond()

-- BluetoothClass --
BluetoothDevice.ACTION_CLASS_CHANGED
BluetoothDevice.EXTRA_CLASS
BluetoothDevice.getBluetoothClass()
BluetoothClass.Service.*
BluetoothClass.Device.Major.*
BluetoothClass.Device.*
BluetoothClass.getDeviceClass()
BluetoothClass.getMajorDeviceClass()
BluetoothClass.hasService()

-- Misc BluetoothDevice --
BluetoothDevice.ACTION_ACL_CONNECTED
BluetoothDevice.ACTION_ACL_DISCONNECTED_REQUESTED
BluetoothDevice.ACTION_ACL_DISCONNECTED
BluetoothDevice.ACTION_DISCOVERED
BluetoothDevice.ACTION_NAME_CHANGED
BluetoothDevice.EXTRA_DEVICE
BluetoothDevice.EXTRA_NAME
BluetoothDevice.EXTRA_RSSI

-- Misc BluetoothAdapter --
BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED
BluetoothAdapter.EXTRA_LOCAL_NAME
BluetoothAdapter.checkBluetoothAddress()

I deprecated BluetoothIntent and moved each intent into the class it relates
to.

Change-Id: I877b1280428ab46278b2bc25668bb44cda22dc36
/frameworks/base/media/java/android/media/AudioService.java
dc1d17a1dbfc2ae01c20012133a836b62f5b6930 10-Sep-2009 Eric Laurent <elaurent@google.com> Fix issue android.permission.cts.NoAudioPermissionTest:testRouting is failing.

Add audio permission checks in setSpeakerphoneOn() and setBluetoothScoOn() methods.
/frameworks/base/media/java/android/media/AudioService.java
78333dd750c7353e47163407a662ef39a3c6b24a 27-Aug-2009 Jaikumar Ganesh <jaikumar@google.com> Set Routing to A2DP only when state is Connected.

We were setting the routing to A2DP when the state was Connecting too.
This was incorrect and can cause problems. One such problem was when
handling an incoming connection we set the routing to A2DP before
authorization. And even if authorization succeeds we get out sync with
AVDTP command state.
/frameworks/base/media/java/android/media/AudioService.java
6ee9952bc20be72b9419cb653c9e2e833889a3d3 25-Aug-2009 Eric Laurent <elaurent@google.com> Fix issue 2076322: AudioService, too many stream volume steps.

MAX_STREAM_VOLUME[] now contains the maximum valid index instead of the number of indexes for all stream types.
/frameworks/base/media/java/android/media/AudioService.java
a56d1c72190462aa9e377906583eceb58e0efcdd 19-Aug-2009 Nick Pelly <npelly@google.com> Fix AudioService on HFP power off due to new Bluetooth API.

HEADSET_STATE_CHANGED_ACTION contains a null BluetoothDevice when the HFP
disconnects.
/frameworks/base/media/java/android/media/AudioService.java
bd022f423a33f0794bb53e5b0720da2d67e4631c 15-Aug-2009 Nick Pelly <npelly@google.com> Bluetooth: API change.

Split BluetoothDevice into BluetoothDevice and BluetoothAdapter.

BluetoothAdapter: Represents the local BT adapter. Operations on the local
adapter (start a scan, etc).
BluetoothDevice: Represents a remote BT device. Operations on remote devices
(pair, connect, etc).

IBluetoothDevice.aidl -> Bluetooth.aidl
BluetoothDeviceService.java -> BluetoothDeviceService.java

TODO:
Javadoc
/frameworks/base/media/java/android/media/AudioService.java
5982013cfc8274ff0bafaba83c676b3a8890cba9 14-Aug-2009 Jared Suttles <jared.suttles@motorola.com> Change the number of volume steps from 6 to 7 per Verizon Requirements

Submitted on behalf of Helen Tran <Helen.Tran@motorola.com>
Signed-off-by: Jared Suttles <jared.suttles@motorola.com>
/frameworks/base/media/java/android/media/AudioService.java
d5603c126acdd94d9f7400bb1d04188020a425b4 06-Aug-2009 Eric Laurent <elaurent@google.com> AudioService now differentiates BT headsets and car kits.

The BT headset detection now makes the difference between car kits and headsets, which can be used by audio policy manager.
The headset connection is also detected earlier, that is when the headset is connected and not when the SCO socket is connected as it was the case before. This allows the audio policy manager to suspend A2DP output while ringing if a SCO headset is connected.
/frameworks/base/media/java/android/media/AudioService.java
c42ac9d4d03f62c3a1ba197a28a81fda44bd8b7f 29-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 2019031: Volume changes have no effect.

Send initStreamVolume() for each stream when media server restarts.
Also added restoring of phone state, device connection state and forced device for communications.
/frameworks/base/media/java/android/media/AudioService.java
d25ae67ca8f003ada2881154514523d8614d4b7e 27-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 2004738: Settings Backup Agent consistently throws ArrayIndexOutOfBoundsException during restore.

Use stream alias when accessing VOLUME_SETTINGS array.
/frameworks/base/media/java/android/media/AudioService.java
a553c25b33c99b345cf1c8688f8df0ed8df14e5a 17-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1795088 Improve audio routing code

Initial commit for review.
Integrated comments after patch set 1 review.
Fixed lockup in AudioFlinger::ThreadBase::exit()
Fixed lockup when playing tone with AudioPlocyService startTone()
/frameworks/base/media/java/android/media/AudioService.java
fd6e4820c6ee91c9c232a7598c1e45c002b868e7 17-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1985479 lots of backup NPEs.

Check that stream type is not STREAM_BLUETOOTH_SCO before writting to settings.
/frameworks/base/media/java/android/media/AudioService.java
4050c93601b3c3609b21cc1e18a29b64747e7fa9 08-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1967295: Add a method to request reloading of audio settings by AudioService.
/frameworks/base/media/java/android/media/AudioService.java
d1f362fe144e6cbcb759fa9086a80adbfe9c7589 16-Jun-2009 Mike Lockwood <lockwood@android.com> AudioService: Fix routing problem recently introduced in setRouting().

Do not disable a route unless routes is zero, to avoid accidentally disabling
if the same route is enabled twice in a row.

Signed-off-by: Mike Lockwood <lockwood@android.com>
/frameworks/base/media/java/android/media/AudioService.java
9bcf401d13d47416043a704430388abd59aef7cd 12-Jun-2009 Eric Laurent <elaurent@google.com> Fix issue #899198 MODE_RINGER_STREAMS_AFFECTED does not restore volumes correctly

The problem is that setRingerModeInt() does not handle streams not affected by ringer mode: when enabling "Alarm in silent mode" while in silent mode, setRingerModeInt is called after alarm streamis removed from ringer mode affected streams, and nothing is done.

The fix constists in also processing streams that are not affected by ringer mode and to restore last audible volume for them. It does not arm reapplying the volume for streams the are never affected by ringer mode as we don't do this very often.

The other problem noted in the bug report (ringer volume always restored to non zero value when exiting silent mode even if set to zero before) is also fixed: a new parameter is added to setIndex() and setStreamVolumeInt() to explicitely request to store the volume index as last audible instead of doing it automatically if index > 0.
/frameworks/base/media/java/android/media/AudioService.java
b9c9d260f21b321527c4622a123af9767630d94d 06-May-2009 Eric Laurent <elaurent@google.com> fix issue 1713090: After a Bluetooth call, MusicPlayer starts playing on speaker rather than wired external audio.

Temporary fix until audio routing is refactored in Eclair release:
- centralized and synchronized all audio routing control in AudioService.setRouting()
- deprecated AudioManager.setRouting() and AudioManager.getRouting() methods
/frameworks/base/media/java/android/media/AudioService.java
1a9f7399bb32c81ad5cc8c9d74ab3065b4a150ac 25-Mar-2009 Niko Catania <> Automated import from //branches/donutburger/...@140800,140800
/frameworks/base/media/java/android/media/AudioService.java
b109615ebebd6f3b9ae789412279f576c3ace46b 25-Mar-2009 Jason Parekh <> Automated import from //branches/donutburger/...@140507,140507
/frameworks/base/media/java/android/media/AudioService.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/media/java/android/media/AudioService.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/media/java/android/media/AudioService.java
3001a035439d8134a7d70d796376d1dfbff3cdcd 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
/frameworks/base/media/java/android/media/AudioService.java
da996f390e17e16f2dfa60e972e7ebc4f868f37e 13-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@131421
/frameworks/base/media/java/android/media/AudioService.java
d24b8183b93e781080b2c16c487e60d51c12da31 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/base/media/java/android/media/AudioService.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/media/java/android/media/AudioService.java
54b6cfa9a9e5b861a9930af873580d6dc20f773c 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/base/media/java/android/media/AudioService.java