Commit Graph

31 Commits

Author SHA1 Message Date
Kyunglyul Hyun
581fc98d65 MediaRouter: enable transferring from/to BT devices.
The main objective of this CL is to enable selecting BT device.
For that it updates MRM and SystemMediaRoute2Provider such that
  - MRM.getRoutingControllers() returns a list including the system session
  - SystemMediaRoute2Provider marks routes as "transferable"
  - SystemMediaRoute2Provider sets provider id correctly
  - SystemMediaRoute2Provider handles transferToRoute()

Bug: 147979868
Bug: 147122575

Test: atest mediaroutertest
&& manually selecting phone / bt devices from output switcher

Change-Id: I2e2032fd6677f79b9f864c313c40846daa87f113
2020-01-22 20:46:22 +09:00
Kyunglyul Hyun
c6583833d4 Revert "Revert "MediaRouter: add routing controller in MRM""
This reverts commit 7d720f70be.

Reason for revert: Fixed the build issue

Test: atest mediaroutertest

Change-Id: I6cae922d701640a1f43965041c653bd7a61411cb
2020-01-17 20:48:57 +09:00
Kyunglyul Hyun
7d720f70be Revert "MediaRouter: add routing controller in MRM"
This reverts commit b3dacf3d56.

Reason for revert: Build Fail (ab/6143227)

Change-Id: I456d1ffe4a9760e65f91c37cd67bb9e9daabcc8e
2020-01-17 11:03:28 +00:00
Kyunglyul Hyun
b3dacf3d56 MediaRouter: add routing controller in MRM
This CL introduces RoutingController into MediaRouter2Manager
to enable it to control remote routing sessions.

Tests are also revised according to MRM changes.

Bug: 147787194
Test: atest mediaroutertest

Change-Id: Id4ab61fcb690fccac42df049e1fb74d89bcf3d6a
2020-01-17 15:52:00 +09:00
Hyundo Moon
f829e6f1d6 Rename RouteSessionInfo and RouteSessionController
This CL renames following classes:
 - RouteSessionInfo to RoutingSessionInfo
 - RouteSessionController to RoutingController

Bug: 147527788
Test: atest mediaroutertest
Change-Id: I6d6c997d9119b668bd8879f2f5a8ca266ddbeccc
2020-01-11 19:56:37 +09:00
Kyunglyul Hyun
616096e8d0 Unhide MediaRouter2 and MediaRoute2ProviderService
This CL covers APIs for discovering routes published by
MediaRoute2ProviderService.

Bug: 147402721
Test: atest mediaroutertest
Change-Id: I978a6489ae1bcfcd6bb427d4a939c49ff3420e2d
2020-01-11 16:09:35 +09:00
Kyunglyul Hyun
91c792e4a0 MediaRouter: Introduce discovery request
Providers are notified of change of discovery request
to respond properly.

Whenever a media app registers a callback it should provide
discovery request which includes route types and a way to scan.

MediaRouter combines all discovery request into a single request
and sends it to the media router service, which combines requests
from all clients and notifies provider of the combined request.

This CL also changes control category as route type.

Bug: 139033746
Test: atest mediaroutertest
Change-Id: I5ca37683ae0761ff587c1c920e32fd6d768a2cd3
2020-01-09 15:12:15 +09:00
Hyundo Moon
b7dc082b05 Make MediaRoute2Info#getId() unique in client side (MR2/Manager)
This CL makes MediaRoute2Info#getId() return a unique ID when it is
called for routes which were get via MediaRouter2 / MediaRouter2Manager.

Acordingly, this CL removes MediaRoute2Info#getUniqueId().

Bug: 147338138
Test: atest mediaroutertest
Change-Id: Id2960c45e9cabde7bc5b57554608aebe03fcbe04
2020-01-08 17:52:45 +09:00
Kyunglyul Hyun
efe4374eb4 MediaRouter: save sessions in media router service
Each MediaRoute2Provider instance saves session infos
published by MediaRoute2ProviderService.

For that, MediaRouter2ProviderService notifies provider info and session
infos simultaneously and to minimize the number of binder calls,
schedulePublishState is added into MediaRoute2ProviderService.

The saved sessions can be obtained by calling MRM.getActiveSessions().

Test: atest mediaroutertest
 && manually call MRM.getActiveSessions()

Change-Id: I6938105f8d154ad9542f7e7c6210a451ee4ae90d
2019-12-31 22:12:29 +09:00
Kyunglyul Hyun
c7847244ea MediaRouter: make request id globally unique
A unique request id can be used to identify each request
and the client of the request.

Test: atest mediaroutertest
Change-Id: I3234eaf0c4d398a47d412bc13ce711165d87e2db
2019-12-31 14:26:36 +09:00
Kyunglyul Hyun
cb8894dbc7 MediaRouter: add session related apis into provider
This CL adds session-related apis into MediaRouteProvider
so MediaRouterService can call them.

This CL also removes methods related to "route selection".

Test: atest mediaroutertest
Change-Id: I68c2cde91d305315e95e5d9ab1d6d23459c28c9d
2019-12-30 16:58:19 +09:00
TreeHugger Robot
b9a35bbaff Merge "MediaRouter2: add MRM.getActiveRoutes" 2019-12-20 10:18:42 +00:00
Kyunglyul Hyun
86998f446b MediaRouter2: add MRM.getActiveRoutes
This method will list up routes that are actively used
by some applications.

Once dynamic grouping is implemented, it will return
sessions instead of routes.

Bug: 146604082
Test: atest mediaroutertest

Change-Id: Ic013d3c2ded47b7ebca0b4cf99d2a7ea75045dc1
2019-12-20 17:45:24 +09:00
Kyunglyul Hyun
5c9a55ea9a MediaRouter: Renames supportControlCategory as supportControlCategories
Also adds a supportControlCategory that checks a single category.

Test: atest mediaroutertest
Change-Id: If878aa7df89fb61b38b52abad0adedccacb6df21
2019-12-20 17:29:59 +09:00
Kyunglyul Hyun
484074aedb MediaRouter: make setControlCategories synchronous
MR2.getRoutes() right after MR2.setControlCategories() will return
routes filtered with new control categories.

In order to call backs properly, mHandledControlCategories is added,
which is changed only in handler.

getRoutes() is also changed such that routes are evaluated lazily
to avoid unnecessary evaluation.

CallbackRecords are implemented in a way that doesn't acquire explicit
lock.

Callbacks are modified so that newly register callbacks no longer
get notified existing routes.

Also, fixed test according to changes of MR2 and MRM.

Bug: 145488462
Test: atest mediaroutertest (5 times)
Change-Id: I9ba3d74bcf423d801249420d947f41eccb37d67a
2019-12-16 15:50:38 +09:00
Kyunglyul Hyun
4ed68757a7 MediaRouter2: Updates callback for MediaRouter2Manager
This CL updates callbacks for MediaRouter2Manager such that
onRoutesAdded, onRoutesRemoved are added and onRoutesChanged is changed.

onControlCategories also is added to know when getAvailableRoutes() can
be called.

It also updated tests for that and add some helper methods to test
easily.

Test: atest mediaroutertest

Change-Id: I122ce8f8472e01284f13b8aec79e3b8e97fc712b
2019-11-11 13:59:05 +09:00
Kyunglyul Hyun
7af7301eb8 MediaRouter2: Revise MediaRouter2.Callback.onRoute**
This CL revised callbacks for MediaRouter2 so that it gives
a list instead of a single route.
This will effectively reduce the number of invokings.

This CL also fixes binder call between media router service and media
router such that media router service notifies only changes of routes
instead of all provider information.

Following CLs will update manager callbacks as well.

Test: atest mediaroutertest
Change-Id: Ibbc23aa5f12f5450d44c81756e3fcefe3e0d7f4b
2019-10-31 16:46:25 +09:00
TreeHugger Robot
268294f394 Merge "MediaRouter2: Make TAGs have common prefix 'MR2'" 2019-10-17 10:06:43 +00:00
Hyundo Moon
7d3ab337da MediaRouter2: Make TAGs have common prefix 'MR2'
Also does some minor fixes.

Test: Builds successfully
Change-Id: Ied4b1cc87241a7cb167959e8c452b0dcdea6b3b4
2019-10-17 17:07:37 +09:00
Kyunglyul Hyun
5a8dedcf8a MediaRouter: add volume control functionality into MR2
Add requestSetVolume and requestUpdateVolume into
MediaRouter2 and MediaRouter2Manager to enable users to control volume
of routes.

This CL also includes test cleanup for readability.

Bug: 142298160
Test: atest mediaroutertest
Change-Id: Iebb396c921517ec1a7677f90baa119ab647b5689
2019-10-11 16:43:36 +09:00
Kyunglyul Hyun
23b3aaa464 Media: add MediaRouter2.getRoutes()
As with this CL, media apps can get the list of available routes using
MediaRouter2.getRoutes() or MediaRouter2.Callback.onRouteListChanged().

For that MediaRouterService notifies MediaRouter2 of providerinfos.

This CL also clarifies provider info notification logic.

1) When a new client or a new manager is registered, it will be
notified.
2) When a provider info is updated, it will be notified.

onRouteListChanged will be called for a newly registerd callback.

Fixed a bug that MediaRoute2ProviderProxy didn't report state update
when the provider is disonnected.

Test: atest mediaroutertest
Change-Id: I50f5c3cabce80e7fb0a1b5596883c35911d6f122
2019-08-22 17:25:07 +09:00
Kyunglyul Hyun
d1f0b6e0b3 Media: Remove @MainThread from MediaRouter2
Now it uses mLock to synchronize mCallbackRecords, mControlCategories,
and mClient instead of enforcing main thread.

Also, check concurrency of MediaRouter2 and MediaRouter2Manager.

This CL also removes control category parameter from addCallback(registerCallback)
not to permit two callbacks in an application to have different control categories.

Function names are changed from add/remove callbacks to register/unregister callbacks
to follow the API guideline.

Test: atest mediaroutertest

Change-Id: I40f2bc45f7d108416182b68b4ae23127f8bb2eb4
2019-08-12 12:33:12 +09:00
Kyunglyul Hyun
e23e5ed72b Media : Implement getAvailableRoutes in MediaRouter2Manager
This CL adds capability to media route 2 info, which can be used
to get available routes for each app, which set control categories.

The test for control category is changed to test getAvailableRoutes().

Test: atest mediaroutertest

Change-Id: If93d64f02b4868b5e04b737431291b18a52177de
2019-07-17 17:00:04 +09:00
Kyunglyul Hyun
a0d47419e3 Media: Implement Seamless Transfer with a single provider.
Seamless transfer for a single provider case and two providers case
should be dealt with in different ways.

For a single provider case, the provider can handle transfer and returns
the result of transfer.

For multiple providers case, the media app handles the transfer.

This CL covers seamless transfer within a single provider.

If a user requests semless transfer in System UI, MR2Manager.selectRoute
should be called and this request is sent to MediaRoute2ProviderService
that can handle seamless transfer internally.

The new test, testSingleProviderSelect() in MediaRouterManagerTest tests the path for
seamless transfer and ensure transfer request is handled by a provider.

From this CL, we use packagename instead of uid to select app for seamless transfer.
This is required to handle unlaunched apps that don't have uid.
It would prevent to use media router 2 in a multi-user case, that will
be supported by another CL.

I also added onUnselectRoute in MediaRoute2ProviderService, which is
essential to notify a provider that a media app stopped casting.

Bug: 136775407
Test: atest mediaroutertest

Change-Id: Ie3d0e988a72eedea6036f465454e661c424a0495
2019-07-09 17:18:52 +09:00
Kyunglyul Hyun
13bc105b80 MediaRouter: Make MR2M.CB.onRouteSelected to be called
With this, MediaRouter2Manager.Callback.onRouteSelected will be called properly.

This CL also adds provider id to MediaRoute2Info to distinguish routes
with the same id from different providers.

Test: atest mediaroutertest

Change-Id: If353a4decad489576a39b1a93c7d99c7fe238abe
2019-06-25 14:29:02 +09:00
Kyunglyul Hyun
caae8dc81f Media: Introduce MediaRouter2
Instead of extending MediaRouter, this CL introduce MediaRouter2 class.
This will prevent regression from chaing MediaRouter and we can easily
modify and test `new' features.
For MediaRouter2, IMediaRouter2Client is also added to differentiate the
previous router and the new one in MediaRouterService.

This CL also contains MediaRouter2.sendControlRequest which can be used
to manipulate media routes.
(It is temporarily being used to test MediaRouter2Manager callbacks.)

Bug: 132138073
Test: atest mediaroutertest (w/ mediarouteprovider installed)

Change-Id: I895fe456e38d437cec8e3ca9501cd7f105c5f4d6
2019-05-23 16:48:46 +09:00
Kyunglyul Hyun
6c5d7dcb4f Media: add onRoute*** callback
Make onRouteAdded/Changed/Removed available in
MediaRouter2Manager.Callback

Currently onRouteAdded is only included in the test.
(onRouteRemoved is not called properly due to not handling removed
providers correctly).

Bug: 130875543

Test: atest mediaroutertest w/ mediarouteprovider installed

Change-Id: Idd1fdaeb9fcf1c4b8c2b7798c3ed62eeb044d2cb
2019-05-13 12:33:03 +09:00
Kyunglyul Hyun
3aedf02540 Media: enables MR2PS to update provider info
With this CL, MediaRoute2ProviderService can update its provider info
and publish its routes.

MediaRouter2Manager.Callback.onProviderUpdated(info) is alao added to
confirm whether correct provider info is sent.

Also, renamed the AIDLs such as
  IMediaRouter2ManagerClient -> IMediaRouter2Manager
  IMediaRoute2Callback -> IMediaRoute2ProviderClient

and changed on** to notify** in AIDLs.

Logics related to selecting/unselecting will be coverd by following CLs.

Test: atest mediaroutertest (after atest mediarouteprovider)

Change-Id: I5b119fbd0622a9422d3edf720b85e296ac4a5694
2019-04-22 20:11:47 +09:00
Kyunglyul Hyun
d51666de42 DO NOT MERGE: Revert "DO NOT MERGE: Revert "Media: Add MediaRouterManager to control media route of other apps""
This reverts commit dd3f305bb3.

Reason for revert: wrong branch

Change-Id: Ic9b6d17af8e967ec73a9dac141c60e02195a8d19
2019-04-11 04:10:25 +00:00
Kyunglyul Hyun
dd3f305bb3 DO NOT MERGE: Revert "Media: Add MediaRouterManager to control media route of other apps"
This reverts commit 1c8188f2b4.

Test: atest android.media.cts.MediaRouterTest
Change-Id: I1de6fbeb81b1d5ef0ec4b73173b6525d4c6edc07
2019-04-10 11:56:00 +09:00
Kyunglyul Hyun
1c8188f2b4 Media: Add MediaRouterManager to control media route of other apps
This CL is a draft for supporting seamless transfer

MediaRouterManager is added to notify providers seamless transfer request.

It also adds MediaRouter.setControlCategories() to let application notify
their control categories and filter out irrelevant routes.

Test: atest mediaroutertest after installing mediarouteprovider.apk

Change-Id: I7446855271d27ffaad2e82dda133bed80b9f9630
2019-03-18 14:23:38 +09:00