Commit Graph

7705 Commits

Author SHA1 Message Date
Andy Hung
d5701f0ecb Merge "AudioTrack: getLatency continues UnsupportedAppUsage" into qt-dev 2019-04-10 00:38:42 +00:00
Andy Hung
ce795489ee AudioTrack: getLatency continues UnsupportedAppUsage
Exoplayer needs this API for devices with timestamp issues.

Test: compiles
Bug: 112561552
Bug: 130237544
Change-Id: I136d80011765ac83be8f5258c4ba139ee1f1ef75
2019-04-09 13:30:33 -07:00
Tobias Thierer
79dd28f874 Merge changes I4e32a588,I202c5653 into qt-dev
* changes:
  Make MediaHTTPConnection thread safe.
  Revert "MediaHTTPConnection: move connection states into an inner class"
2019-04-08 18:15:39 +00:00
Tobias Thierer
5b9febae78 Make MediaHTTPConnection thread safe.
MediaHTTPConnection's public methods are called from multiple Binder
threads. Since both HttpURLConnection and access to the various
connection related fields is not thread safe, this CL guards most
methods by a single lock. This means that the methods can now block
when called, although this should be rare:

 - there are two processes that call these methods. One process
   only calls getSize(), and the other process calls methods
   from a single thread (ie. at not overlapping clock times).
 - should lock contention unexpectedly increase in future, then
   that would be bad (because Binder thread pool threads would
   be blocked/unavailable), but it would not be easy to detect.
   It would be easy to detect if we could stop getSize() being
   called at overlapping clock times, since we could then use
   ReentrantLock.tryLock() to assert that the lock is never contended
   outside of disconnect().

Because it's a requirement for disconnect() to quickly stop another
thread that is blocked in readAt(), disconnect() is the only method
that doesn't acquire the lock immediately; the mConnection field
is marked volatile so that disconnect() has a high chance of reading
that field and calling disconnect() on it without waiting for
another thread (there's a small risk that another thread might
acquire the lock and start a new connection while disconnect()
is waiting for the lock; in that case, after acquiring the lock,
disconnect() will also disconnect that new connection; this is
subject to potential change in future.

Initially, a ReentrantLock object was considered but for now this
CL instead uses the synchronized lock on "this" because:

 - it minimizes churn on the lines of code in this file because
   synchronized (this) { } can be expressed by introduction of
   the word "synchronized" on the method header, whereas
   mLock.lock(); try { ... } finally { mLock.unlock(); } would
   indent all the lines in-between and thus pollute git annotate.
 - some methods were already synchronized.
 - ReentrantLock.tryLock() is not used for now; most of the time,
   lock acquisition should be uncontended but the two cases of
   lock contention mentioned above exist, which makes it difficult
   to distinguish surprising from unsurprising lock contention.
   While this is the case, it seems better to keep the code
   simple and to just unconditionally block.

Bug: 114337214
Fixes: 114337214
Fixes: 119900000
Fixes: 129444137
Fixes: 128758794
Fixes: 63002045

Test: Checked manually that bug 114337214 no longer reproduces on
      Android API level 27 (Oreo MR1) after cherrypicking this CL.
Test: Ran the following on internal master with this CL:
      make cts && cts-tradefed run cts -m CtsMediaTestCases \
      -t android.media.cts.NativeDecoderTest#testAMediaDataSourceClose \
      --abi arm64-v8a
Test: Ran the following both on AOSP (158 tests) and internal master (178):
      atest CtsMediaTestCases:android.media.cts.{MediaPlayer{,2},Routing}Test

      All these tests pass except that on AOSP only, the following test
      fails both before and after my CL (appears unrelated):
      android.media.cts.RoutingTest#test_MediaPlayer_RoutingChangedCallback

(cherry picked from commit 8d9fccee62)

Change-Id: I4e32a58891c3ce60ddfa72d36060486d37906f8d
Merged-In: I4e32a58891c3ce60ddfa72d36060486d37906f8d
2019-04-08 18:14:42 +00:00
Tobias Thierer
241377b10a Revert "MediaHTTPConnection: move connection states into an inner class"
This reverts commit 621e7968ad.

Many of the fields that were moved are annotated @UnsupportedAppUsage,
so the CL would have had undesirable app compat impact. Further,
because investigation has revealed that lock contention *is* possible,
we need to always acquire the lock anyway so there is no longer a
benefit in keeping all of the mutable state in a single field that
can be atomically set to null.

Bug: 114337214
Test: Treehugger

(cherry picked from commit dc9f4b4d5d)

Change-Id: I202c5653cb086d99228491e161a159bad640105a
Merged-In: I202c5653cb086d99228491e161a159bad640105a
2019-04-08 18:14:04 +00:00
Eric Laurent
960c4f06ae Merge "fix AudioAttributes matching rule in AudioProductStrategy" into qt-dev 2019-04-05 16:00:00 +00:00
Eric Laurent
f83192de79 Merge "Revert "Revert "Mute haptic channels by default.""" into qt-dev 2019-04-05 16:00:00 +00:00
Wonsik Kim
b06132ad90 media: fix documentation for MediaFormat.KEY_PREPEND_HEADERS_TO_SYNC_FRAMES
Bug: 32746212
Test: builds
Change-Id: I38ecfa879091bc4016fbae04eab77ed6fd9eb1c1
2019-04-04 12:54:59 -07:00
Eric Laurent
c9d353dcf8 Revert "Revert "Mute haptic channels by default.""
This reverts commit e6243996ef.

Bug: 129721367
Test: change volume in Play Music
(cherry picked from commit ab3a3f8c02)

Change-Id: Id6e63e87265717130dde0e1b46e28edbb0b53edb
2019-04-04 18:07:25 +00:00
Eric Laurent
337a86626e fix AudioAttributes matching rule in AudioProductStrategy
The matching rule on audio attributes flags must be that ALL flags
set in the reference attributes are present in the compared attributes
and not just some flags.

Bug: 129721367
Test: change volume in Play Music
Change-Id: I462fd73fb9b78b094411c6f3b52004349f49bcf3
(cherry picked from commit 9b0bb840cd)
2019-04-04 18:07:02 +00:00
TreeHugger Robot
23961b92bb Merge "Add AudioAttribute flag missing in FLAG_ALL" 2019-04-03 21:18:17 +00:00
Jean-Michel Trivi
c6d7460140 Merge "PlayerBase: conditional muting on OP_PLAY_AUDIO changes" 2019-04-03 19:58:59 +00:00
Kevin Rocard
506541c1d1 Add AudioAttribute flag missing in FLAG_ALL
Test: Compile
Bug: 111453086
Change-Id: I09212262f56253decd48fd9204404e744f0772ab
Signed-off-by: Kevin Rocard <krocard@google.com>
2019-04-03 12:45:01 -07:00
Eric Laurent
e6243996ef Revert "Mute haptic channels by default."
This reverts commit 48af5aeeba.

No idea on how this simple CL can cause this problem but A/B tests
and bisection show that the problem disabpears when reverted.

Bug: 129721367
Test: no repro on build with revert.
Change-Id: I13e3d788d255c4b6e873bb1e9ce2cf92d2a18e41
2019-04-02 18:59:12 -07:00
TreeHugger Robot
bb261a3caf Merge "Fix ringtone null pointer exception" 2019-04-02 20:23:35 +00:00
Youming Ye
33c666d955 Fix ringtone null pointer exception
Bug: 128468578
Test: Build
Change-Id: If65f0194712c8358fdbd88e7d04478f8395a012b
2019-04-02 19:53:15 +00:00
TreeHugger Robot
2118cc3042 Merge "Mute haptic channels by default." 2019-03-31 22:52:58 +00:00
jiabin
48af5aeeba Mute haptic channels by default.
In case the apps start vibration while playing asserts containing haptic
channels, it will be safer to mute haptic channels by default. Apps will
need to explicitly enable haptic channels if they want haptic via audio.

Bug: 129544270
Test: play with/without enabling haptic channels.
Change-Id: Id35d25c2be1c0b26053389f0b277b1ce321ad29e
2019-03-29 11:05:47 -07:00
TreeHugger Robot
dcb8edfc4d Merge "MediaRecorder: Add IntDef to setAudioSource" 2019-03-28 20:14:17 +00:00
TreeHugger Robot
20309bb9c3 Merge "Remove deprecateStreamTypeForPlayback from HwAudioSource" 2019-03-28 19:38:19 +00:00
TreeHugger Robot
9ad0766f16 Merge "Add application wide capture policy" 2019-03-28 19:37:13 +00:00
Hongwei Wang
50b1abc246 Merge changes from topic "renault-non-api-change"
* changes:
  Get volume indexes from Audio Policy Service
  Use AudioProductStrategies within AudioAttributes
2019-03-28 08:21:59 +00:00
Kevin Rocard
cba4b211e5 Merge "Introduce a system APC with its corresponding opt-out" 2019-03-27 20:41:06 +00:00
TreeHugger Robot
49cf94e9d4 Merge "media: rename KEY_MAX_BFRAMES to KEY_MAX_B_FRAMES" 2019-03-27 20:30:47 +00:00
Hongwei Wang
ace9250688 Remove deprecateStreamTypeForPlayback from HwAudioSource
It used to be there to hide from API list, and since it's been addressed
in PlayerBase, this pseudo override is no longer needed.

Bug: 126702177
Test: make system-api-stubs-docs-update-current-api
Change-Id: I8caa75410d1ffb2b0e690a82396ac978b03a2844
2019-03-27 11:24:34 -07:00
Wonsik Kim
d18e1f34fe media: rename KEY_MAX_BFRAMES to KEY_MAX_B_FRAMES
Rename it to be consistent with use of I_FRAME.

Bug: 129344870
Test: builds
Change-Id: I816439074837452cdbd9ed2a734ea237517ad26f
2019-03-27 08:49:58 -07:00
Hyundo Moon
4e953bb406 Merge "Remove ControllerCallbackLink" 2019-03-27 00:20:14 +00:00
Jeff Sharkey
02aefee533 Merge "Unify media permissions enforcement in framework." 2019-03-26 23:54:22 +00:00
Jeff Sharkey
859856d8d6 Unify media permissions enforcement in framework.
This opens the door to the same consistent logic being shared by
anyone across the OS who wants to enforce storage permissions.

Bug: 126788266
Test: atest --test-mapping packages/apps/MediaProvider
Exempted-From-Owner-Approval: Trivial permissions refactoring
Change-Id: I3107425f8dafa6ba05918bb67c3c0cb5d3899657
2019-03-26 23:54:08 +00:00
Hyundo Moon
4e4459b403 Remove ControllerCallbackLink
Bug: 129323028
Test: atest CtsMediaTestCases:android.media.cts.MediaSessionTest;
      atest CtsMediaTestCases:android.media.cts.MediaControllerTest;
      atest CtsMediaTestCases:android.media.cts.MediaBrowserTest;
      atest CtsMediaTestCases:android.media.cts.MediaSessionManagerTest;
Change-Id: I5b1fedc70cee7311364925562ad253a68b2bfe6e
2019-03-26 20:05:29 +09:00
Kyunglyul Hyun
2d70f04a1d Merge "Media: Add MediaRouterManager to control media route of other apps" 2019-03-25 23:39:34 +00:00
Jean-Michel Trivi
fcf1e54d29 PlayerBase: conditional muting on OP_PLAY_AUDIO changes
Do not mute based on OP_PLAY_AUDIO client side.
Disable legacy behavior with constant without affecting
  audio service logs.

Bug: 112339570
Test: enter DnD, play notifications, verify not heard
Change-Id: I8a963af02fc2b42844470a4212fec8e2f6a5e4e0
2019-03-25 16:13:41 -07:00
Jeff Sharkey
ff200957fd Query specific collections for properties.
We're now enforcing the public API schema, so clients like MTP need
to query specific collections when asking for properties that are
specific to those media types.

Also refactor MediaScanner calls to go through MediaProvider, so
they can be handled by ModernMediaScanner.  We no longer directly
try inserting items, and instead rely completely on the scanner.

Bug: 127625964, 122263824
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Ic86982766606a619afafe725f9c60013a5671840
2019-03-24 14:21:01 -06:00
Hyundo Moon
2809f8fe1e Merge "Remove SessionCallbackLink" 2019-03-24 12:15:07 +00:00
Jeff Sharkey
ae80b5417b Merge changes from topic "mar22z"
* changes:
  Point people towards ModernMediaScanner.
  Translate paths before leaving app sandbox.
2019-03-23 17:59:03 +00:00
Eric Laurent
aff8c04b25 MediaRecorder: Add IntDef to setAudioSource
Bug: 128414080
Test: make
Change-Id: I1f0b5c75becf89e995fb33f85a79c834d5fa9625
2019-03-22 18:04:50 -07:00
Michael Wright
f0ae16b7d0 Merge "Add self to OWNERS for MediaProjection." am: 00ccf23ebd am: 187bd825b8
am: 12683c7d9d

Change-Id: I716cf4f93ca453a69e054f3b455cc4ba62be8941
2019-03-22 17:36:20 -07:00
Michael Wright
12683c7d9d Merge "Add self to OWNERS for MediaProjection." am: 00ccf23ebd
am: 187bd825b8

Change-Id: Ic59abd88618d5b06dedf5f618a428f8ab1c4f022
2019-03-22 17:26:57 -07:00
Michael Wright
187bd825b8 Merge "Add self to OWNERS for MediaProjection."
am: 00ccf23ebd

Change-Id: I34369b2d81c8fea7c56000e305ee8f82a18135de
2019-03-22 17:14:39 -07:00
Treehugger Robot
00ccf23ebd Merge "Add self to OWNERS for MediaProjection." 2019-03-22 23:48:31 +00:00
Jeff Sharkey
13d02b5925 Point people towards ModernMediaScanner.
The platform media scanner has served faithfully for many years, but
it's become tedious to test and maintain, mainly due to the way it
weaves obscurely between managed and native code.

Bug: 128243527
Test: none
Change-Id: I44c5e9840acc0afde4aeaf9a44a21e0f8939b44b
2019-03-22 17:30:48 -06:00
TreeHugger Robot
3330585f06 Merge "Add status for license starting in the future" 2019-03-22 22:59:19 +00:00
Kevin Rocard
7919c2acc9 Add application wide capture policy
Apps were previously forced to set their allowed capture policy from
either their manifest which is not flexible or from each track which is
a very fine grain but difficult when using libraries like exoplayer.

Thus add an application level policy set with AudioManager.

Test: atest android.media.cts.AudioPlaybackCaptureTest#testCaptureMediaUsage
Bug: 111453086
Change-Id: Id360f1c3f3157c60694c039e51ff16e71d8f93cd
Signed-off-by: Kevin Rocard <krocard@google.com>
2019-03-22 15:28:51 -07:00
Kevin Rocard
a3a4bbba98 Introduce a system APC with its corresponding opt-out
For system application with the new permission CAPTURE_MEDIA_OUTPUT, or
CAPTURE_AUDIO_OUTPUT, allow to capture the audio of playing apps that
allow it.

Test: adb shell audiorecorder --target /data/file1.raw
Test: atest android.media.cts.AudioPlaybackCaptureTest
Bug: 111453086
Change-Id: I5bfca51e48992234508897c595a076d066db26b2
Signed-off-by: Kevin Rocard <krocard@google.com>
2019-03-22 15:28:51 -07:00
Jeff Tinker
22f157713f Add status for license starting in the future
bug:116738851
Change-Id: Ifd38733f2f5704fbc93d23e6b53994430736dd17
2019-03-22 10:12:00 -07:00
Eric Laurent
b8d4c59b08 Merge "API changes in MicrophoneDirection" 2019-03-22 15:57:49 +00:00
TreeHugger Robot
3d97b27ce0 Merge "Offloaded playback: use AudioAttributes in support check" 2019-03-22 09:20:17 +00:00
Hyundo Moon
7969f77f95 Remove SessionCallbackLink
Bug: 129037153
Test: atest CtsMediaTestCases:android.media.cts.MediaSessionTest;
      atest CtsMediaTestCases:android.media.cts.MediaControllerTest;
      atest CtsMediaTestCases:android.media.cts.MediaBrowserTest;
      atest CtsMediaTestCases:android.media.cts.MediaSessionManagerTest;
Change-Id: I79cd69854fce2448544fd517c1af7d7321df6a79
2019-03-22 15:22:17 +09:00
Hyundo Moon
34cfe56bdc Merge "Remove MediaSessionEngine" 2019-03-22 05:30:13 +00:00
Jean-Michel Trivi
f3fd84adfe Offloaded playback: use AudioAttributes in support check
AudioAttributes can influence offload support, add them in
  method to check for support

Bug: 86837964
Test: cts-tradefed run cts -m CtsMediaTestCases -t android.media.cts.AudioTrackOffloadTest#testAudioTrackOffload
Change-Id: If4037d0611ec1264d23d1779b9ac6efd9fd1244c
2019-03-21 21:21:23 -07:00