This is a partial revert of
I0c12d2b63b0c3969c91e0082f7821e342360b724, which allows a race
condition where the available routes don't include the selected
route, because both collections are obtained without holding the
lock that guards both collections.
While this change doesn't ensure the transferable and selectable
routes of the session are consistent, it does prevent an exception
due to empty selectable routes.
Bug: b/416911854
Test: atest CtsMediaRouterTestCases
Test: Manual using a BT device and a wired headset.
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:d1b3245c261cabcc936af263e3f71b79c9aeecc5
Merged-In: I6a022c6098daf8282e6085bb671173f574e63a4f
Change-Id: I6a022c6098daf8282e6085bb671173f574e63a4f
This enables the sys ui volume slider to show up for volume adjustment
events in mirroring sessions. We still need to change routing session
updates to only show the slider as a result of a hardware volume key
press.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I1fccb4cf3891a1c61c92ea3dad9e97f7b7fc27ce
This is necessary in case SysUI crashes and needs to restart while a
mirroring session is already ongoing.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Ic3866066124f5b4c63dd4569e419a0c1415c702b
This change makes session updates that happen right after a volume key
press include shouldShowVolumeUi = true.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Id7154794171e4dc3447c734a3bb7041b080d09e2
This change is a non-functional refactor that enables the routing
framework to flag that a UI slider should be associated with a given
session update. The purpose of this change is to show the SysUI volume
slider when a mirroring session's volume changes as a result of a
hardware volume key press.
This change only adds the plumbing. The actual functional change to
populate the flag to true comes in a later change.
The approach used in this change mimics the approach used by
AudioManager#FLAG_SHOW_UI and MediaSessionManager#RemoteSessionCallback.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: EXEMPT refactor
Change-Id: I594c110e55eab0b77a7a1e685c55023c5704a9da
This change is a (mostly) non-functional change to improve logging
when the binder transaction to notify a manager of a route discovery
preference change.
Bug: 360129098
Test: Manual simple casting flow using routing demo app
Flag: EXEMPT refactor
Change-Id: Ibee1a2431c2c937bc0aaefb9fc1e451b97dd8148
A system session override is an alteration on how system media is routed
for the app with the override. Per-app dynamic audio routing policies
are an example of overrides. The new listener enables components (like
SysUI) to know which applications have a system session override. And
this, in turn, allows said components to create a Proxy MediaRouter to
control said apps system routing session.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Ia1fda27b0b6402621e37e669283dbbb3763403b1
This change is a (mostly) non-functional change to improve logging
when the binder transaction to notify a manager of a session
creation fails.
Bug: 360129098
Test: Manual simple casting flow using routing demo app
Flag: EXEMPT refactor
Change-Id: If9ee7c7e69254c27630a388737b44925de735d49
This change is a (mostly) non-functional change to simplify the
notification of RLP changes to proxy routers, while also improving the
logging that occurs when the binder transaction fails.
Bug: 360129098
Test: Manual simple RLP flow using routing demo app
Flag: EXEMPT refactor
Change-Id: I7b6a0559f642a3419a2fb3e062d6ad70a93fe8f3
For this, we need to move into a standalone class. We are also renaming
it to AppId.
This is a preliminary refactor for the implementation of volume sliders
for "Cast mirroring" sessions.
Bug: b/396394220
Test: atest CtsMediaRouterTestCases
Flag: EXEMPT refactor
Change-Id: I19504d00240178c0f1981eca34e6172e15abea7c
A handle gives use some more type safety. Plus, it's generally cheaper
to convert a UserHandle to the int id than viceversa.
Bug: 396394220
Test: atest CtsMediaRouterTestCases
Flag: EXEMPT refactor
Change-Id: I587ab0c93b66af9d02990bbd0d8013c299e2b641
This change releases any sessions and resources associated to apps that
are terminated. This enables the sender to disconnect when the re-routed
(aka mirrored) application is terminated.
Bug: b/362507305
Test: CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Ia2cbd5ebf1b869ba61c717bdba3e86125af686ac
The MR2ServiceImpl class is a singleton, and its lifecycle is coupled to
MediaRouterService, who is also in turn a singleton whose lifecycle is
coupled to system_server's lifecycle. So, there's no value in using weak
refs for those classes, as they should never be garbage-collected.
This change gets rid of weakrefs and makes cascade simplifications
without making further invasive changes.
Fixes: b/404574505
Test: atest CtsMediaRouterTestCases CtsMediaHostTestCases
Flag: EXEMPT I don't see how we can flag this change without massive churn.
Change-Id: Ib0dbb04b0540fe4497dc2417872d29f5d9369f93
Releases system media routing (aka mirroring) resources associated with
the given session. This is relevant for the "Stop Casting" button on the
Output Switcher.
Bug: b/396396416
Test: CtsMediaRouterTestCases
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I69dc6f4f316aa3b3841e7f6b8f5ddce5e7c2643b
This reverts commit fc62ef1c75.
Reason for revert: We don't want to support global routing for the first iteration.
Test: atest CtsMediaRouterTestCases:android.media.router.cts.SystemMediaRoutingTest
Bug: b/362507305
Bug: b/413313659
Change-Id: Ic4f1d01f630f3872634ff604fadc42bdafbf71a6
This change replaces stop() with release (which includes a stop under
the hood). This is necessary to ensure resources are freed.
Bug: b/362507305
Test: atest CtsMediaRouterTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Ia0c60fb69144a368c1c279bc4989c2b2e0f6fe6a
We cannot get rid of the flag, because it's exported. But we can assume
the value to be true, which has been the case since Android V. This
simplifies the system routing implementation considerably.
This change is expected to be completely non-functional.
Bug: b/391325457
Test: atest CtsMediaRouterTestCases
Test: atest MediaRouterServiceTests
Flag: EXEMPT code cleanup
Change-Id: I0c12d2b63b0c3969c91e0082f7821e342360b724
The default session is what we show to unprivileged apps as the current
"system output". For example, the built-in speaker, BT, HDMI, etc. By
definition, it's what we show to apps with no privilege, and hence the
release type is always going to be "non-releasable".
Also use RELEASE_UNSUPPORTED if the personal audio sharing flag is
disabled.
Test: Manually using the AndroidX sample routing app.
Bug: 385672684
Flag: com.android.media.flags.enable_output_switcher_personal_audio_sharing
Change-Id: I454082dd44a78d38f2836e97861a13174b5a3fbe
The old bug id was a spotify-specific component to which gantry has no
access.
Bug: b/410871506
Bug: b/418245099
Test: EXEMPT aconfig update
Flag: com.android.media.flags.hide_bt_address_from_apps_without_bt_permission
Change-Id: I730d262e442032460274a9a1236bd61f95336799
Test: atest CtsMediaRouterTestCases
Test: atest CtsMediaHostTestCases
Test: Manually using media routing demo app and 3rd party media app
Bug: b/416436531
Flag: com.android.media.flags.enable_fix_for_route_visibility
Change-Id: I81c1e7faabf2483aba57352795994cb1f7f8de00
This fixes an issue that already existed before mirroring, but was
surfaced as a result of mirroring changes because mirroring triggers
updates in the system session.
The system session (which is populated with AudioManager routes) is
created in system_server without a package name, and then each router
takes care of populating the package name. There was a gap in this
"ensuring the client package name is populated" for system session
updates. But those are uncommon in CTS because they depend on an
AudioManager event, which doesn't happen during CTS. With mirroring,
system session updates become more frequent. This changes fixes the gap.
This gap was detected through MediaRouter2Test#testMediaRouter2ReturnsRoutingSessionInfoWithNonEmptyClientName.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Test: atest CtsMediaRouterTestCases:MediaRouter2Test
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I7995d3ba09379f034a43dcb837db58e8efaa9942
This change doesn't implement the system ui changes, which will come in
a follow up CL.
Bug: b/362507305
Bug: b/396394220
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Icd9b1fa299093dded1ebcd52d31ada6d764be022
This can happen when the media strategy is not available during startup,
so a legacy device route controller is instantiated, instead of the
"correct" audio manager route controller. This change fixes an
implementaiton issue in the legacy route controller, causing it to
return an empty collection of available routes, which is in turn used to
populate the provider info. This change makes the available routes
include the currently selected route.
Longer term, we want to get rid of the legacy route controller but, in
the meantime, this bugfix prevents a crash in sys ui.
Bug: b/357468728
Test: Manually by "forcing" a null media strat.
Test: atest LegacyDeviceRouteControllerTest
Flag: com.android.media.flags.enable_fix_for_empty_system_routes_crash
Change-Id: I5f84bbc9f1102b3df8966be27c7754cd05b53b6b
This enables identifying a mirroring MR2Info object and the
corresponding "remote one" as the same physical receiver device.
Bug: b/396403760
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I54bf41ff9d5f6d87191a9862069fd9e3781ff152
This change is a partial revert of the change with id
Iba0897590d0129ffb0eaf8e152713d582be1fd1f.
Bug: b/379788233
Test: Manually.
Test: atest CtsMediaRouterTestCases
Flag: EXEMPT bugfix
Change-Id: I690f2966aa35cad54cbd1e70de62637f01de530c
Also, pass parameters in a dedicated Params class, to enable future
extensibility without adding overloads, which will presumably be needed
for video.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I0936feefb4c92fe46212ad6bd71ed2b544286cbd
This will enable us to use MediaSessions for other streams that also
support volume adjustment (e.g. mirroring sessions), and not just media
sessions. We can later consider renaming the MediaSessions class to
something like VolumeSessions.
Bug: b/362507305
Test: Presubmit, build and verifying regular volume adjustment
Test: funcionality while casting.
Test: adb shell dumpsys activity service SystemUI | grep -A 100 "VolumeDialogControllerImpl state:"
Flag: EXEMPT Non-functional change
Change-Id: I51739d930d7cdb5b93c58394c699d4b6c3c8567c
This is in preparation for a refactor related to handling volume events
from system media routing sessions (aka mirroring sessions).
Bug: b/362507305
Test: Presubmit, build and verifying regular volume adjustment
Test: funcionality while casting.
Test: adb shell dumpsys activity service SystemUI | grep -A 100 "VolumeDialogControllerImpl state:"
Flag: EXEMPT Non-functional change
Change-Id: I5116a651c8710507b32eb4c25d1b47be8bc0ce86
This change also disables per-app mirroring, because it's not really
supported by the rest of the android system:
- Audio focus prevents two apps from playing at the same time.
- Volume key routing needs substantial changes.
- Volume sliders don't support per-app routing either.
With this change, we can focus on implementing mirroring for the MEDIA
stream across the entire system, and on top of that, start iterating
over towards per-app routing.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I18f86f9f6246498b1b7007efdfafa286e645d7c2
Also change the separate to be an underscore. The dot is already used
for the package name, which is part of the generated original id.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.router.cts.SystemMediaRoutingTest
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I6b078b80bfc970e8b9e4c0822cc460fccd45659d
The naming is confusing when dealing with both the original id and the
unique id.
Bug: b/362507305
Test: presubmit (non-functional refactor)
Flag: EXEMPT Non-functional change
Change-Id: Iefcb9f642519d890469d360963c639d891e2934d
This change is intended to assertively define the role of the media
routing framework in setBTA2dpOn() bugs. In the future, we might
consider merging making this the real behavior but, until then, we can
also use this change to experiment with real usage.
Bug: b/372908448
Flag: com.android.media.flags.disable_set_bluetooth_ad2p_on_calls
Test: atest CtsMediaBetterTogetherTestCases
Test: Manually verified that regular media usecases using 1p and 3p
Test: popular apps work as expected.
Test: Also verified that MediaRouter APIs (legacy and AndroidX) work
TesT: as expected. With the exception of not calling setBTA2dpOn().
Change-Id: I286d61c585c1e6cb20531c659a09f377f72f95a6
This change streamlines the way we log router remote exceptions.
Removing some useless info (like the stacktrace) and adding useful info
(like the router package name).
Bug: b/360129098
Test: Manually by casting and force-stopping the media app.
Flag: EXEMPT Logging only
Change-Id: I887db069583f530c3b7f2f1a6b3c2d073bef6ba0
This CL adds the concept of a global session (note that a default
session exists already), which is the session that's applicable to all
apps unless they have an overriding session (which is a session that
overrides the global session and affects one app specifically).
This means a new capability of the system provider to have one routing
session by default, and then apply specific routing sessions to specific
apps.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases:android.media.bettertogether.cts.SystemMediaRoutingTest --rerun-until-failure
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I6c25f75feb200c86f67e569b07cc6cbef53ac8a3
This change enables the selection of system media routes for any app,
and implements the most important bits of session management, but
doesn't cover everything (for example, this change doesn't cover stream
expansion for system media routing sessions, or routing of the entire
system).
Bug: b/374321232
Test: atest CtsMediaBetterTogetherTestCases CtsMediaHostTestCasts
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: Id43c4568350db068f929d5c6463a079ee28a3471
This change adds info about the provider being added.
Test: Manually (logging change only).
Flag: EXEMPT Logging only
Bug: b/362507305
Change-Id: Ifc9c86d7acd5d2ce56291088f81859eed99ceafd
These are routes that support routing system media, and whose properties
are similar to system-provided routes (like Bluetooth, or Built-in
Speakers).
This change also adds them to the list of transferable routes of the
system routing session, but does not implement transfers in order to
simplify the review. Transfers are coming in a following CL.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases CtsMediaHostTestCasts
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I5950914a8387ea579d22f1bdd2c526f34b6c0758
Privileged is old terminology that hasn't been used in a very
long time.
Bug: b/205124386
Change-Id: I505ef8a2f2fcda1ab55c7f1d88505c4957a5ef8e
Test: N/A javadoc only change.
Flag: EXEMPT documentation only
This will allow the SystemMR2Provider2 to initialize part of the super
class state only after it has initialized its final fields. As part of
this change, we also move non-trivial initialization logic out of the
constructors.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases CtsMediaHostTestCasts
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I6cb572410397ce4b4b8e27a77b1e5488e660b9cf
This changes makes the system bind to any system media route providers,
even if no route discovery preference are set. That's because system
media routing doesn't require apps to declare support for routing.
System media routing is transparent to the app.
Note that this change is non-obviously flagged. The field that indicates
whether a provider supports system media routing is flagged before it's
passed to the MR2ProviderService constructor.
Bug: b/362507305
Test: atest CtsMediaBetterTogetherTestCases CtsMediaHostTestCasts
Flag: com.android.media.flags.enable_mirroring_in_media_router_2
Change-Id: I329fae281ea421a81f5902ceebd8e55ecde0252a