Loading packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java +93 −95 Original line number Diff line number Diff line Loading @@ -142,13 +142,12 @@ public class InfoMediaManager extends MediaManager { * Transfer MediaDevice for media without package name. */ boolean connectDeviceWithoutPackageName(MediaDevice device) { boolean isConnected = false; final RoutingSessionInfo info = mRouterManager.getSystemRoutingSession(null); if (info != null) { mRouterManager.transfer(info, device.mRouteInfo); isConnected = true; return true; } return isConnected; return false; } /** Loading @@ -164,17 +163,16 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.selectRoute(info, device.mRouteInfo); return true; } if (info == null || !info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { Log.w(TAG, "addDeviceToPlayMedia() Ignoring selecting a non-selectable device : " + device.getName()); return false; } mRouterManager.selectRoute(info, device.mRouteInfo); return true; } private RoutingSessionInfo getRoutingSessionInfo() { return getRoutingSessionInfo(mPackageName); } Loading @@ -190,8 +188,7 @@ public class InfoMediaManager extends MediaManager { } boolean isRoutingSessionAvailableForVolumeControl() { List<RoutingSessionInfo> sessions = mRouterManager.getRoutingSessions(mPackageName); List<RoutingSessionInfo> sessions = mRouterManager.getRoutingSessions(mPackageName); for (RoutingSessionInfo session : sessions) { if (!session.isSystemSession() Loading Loading @@ -230,17 +227,16 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.deselectRoute(info, device.mRouteInfo); return true; } if (info == null || !info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { Log.w(TAG, "removeDeviceFromMedia() Ignoring deselecting a non-deselectable device : " + device.getName()); return false; } mRouterManager.deselectRoute(info, device.mRouteInfo); return true; } /** * Release session to stop playing media on MediaDevice. */ Loading @@ -251,31 +247,35 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo sessionInfo = getRoutingSessionInfo(); if (sessionInfo == null) { Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); return false; } if (sessionInfo != null) { mRouterManager.releaseSession(sessionInfo); return true; } Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); return false; } /** * Get the MediaDevice list that can be added to current media. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that can be added to the current {@link * RoutingSessionInfo routing session}. */ List<MediaDevice> getSelectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getSelectableMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectableMediaDevice() package name is null or empty!"); return deviceList; Log.w(TAG, "getSelectableMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.w(TAG, "getSelectableMediaDevices() cannot find selectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getSelectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -283,26 +283,25 @@ public class InfoMediaManager extends MediaManager { return deviceList; } Log.w(TAG, "getSelectableMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; } /** * Get the MediaDevice list that can be removed from current media session. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that can be deselected from the current * {@link RoutingSessionInfo routing session}. */ List<MediaDevice> getDeselectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getDeselectableMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.d(TAG, "getDeselectableMediaDevice() package name is null or empty!"); return deviceList; Log.d(TAG, "getDeselectableMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.d(TAG, "getDeselectableMediaDevices() cannot find deselectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getDeselectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -310,26 +309,26 @@ public class InfoMediaManager extends MediaManager { } return deviceList; } Log.d(TAG, "getDeselectableMediaDevice() cannot found deselectable MediaDevice from : " + mPackageName); return deviceList; } /** * Get the MediaDevice list that has been selected to current media. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that are selected in the current {@link * RoutingSessionInfo routing session}. */ List<MediaDevice> getSelectedMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getSelectedMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectedMediaDevice() package name is null or empty!"); return deviceList; Log.w(TAG, "getSelectedMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.w(TAG, "getSelectedMediaDevices() cannot find selectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getSelectedRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -337,12 +336,6 @@ public class InfoMediaManager extends MediaManager { return deviceList; } Log.w(TAG, "getSelectedMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; } void adjustSessionVolume(RoutingSessionInfo info, int volume) { if (info == null) { Log.w(TAG, "Unable to adjust session volume. RoutingSessionInfo is empty"); Loading @@ -364,15 +357,14 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { Log.d(TAG, "adjustSessionVolume() adjust volume : " + volume + ", with : " if (info == null) { Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); mRouterManager.setSessionVolume(info, volume); return; } Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); Log.d(TAG, "adjustSessionVolume() adjust volume: " + volume + ", with : " + mPackageName); mRouterManager.setSessionVolume(info, volume); } /** Loading @@ -387,15 +379,15 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolumeMax(); } Log.w(TAG, "getSessionVolumeMax() can't found corresponding RoutingSession with : " if (info == null) { Log.w(TAG, "getSessionVolumeMax() can't find corresponding RoutingSession with : " + mPackageName); return -1; } return info.getVolumeMax(); } /** * Gets the current volume of the {@link android.media.RoutingSessionInfo}. * Loading @@ -408,15 +400,15 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolume(); } Log.w(TAG, "getSessionVolume() can't found corresponding RoutingSession with : " if (info == null) { Log.w(TAG, "getSessionVolume() can't find corresponding RoutingSession with : " + mPackageName); return -1; } return info.getVolume(); } CharSequence getSessionName() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "Unable to get session name. The package name is null or empty!"); Loading @@ -424,14 +416,14 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getName(); } if (info == null) { Log.w(TAG, "Unable to get session name for package: " + mPackageName); return null; } return info.getName(); } boolean shouldDisableMediaOutput(String packageName) { if (TextUtils.isEmpty(packageName)) { Log.w(TAG, "shouldDisableMediaOutput() package name is null or empty!"); Loading Loading @@ -473,7 +465,12 @@ public class InfoMediaManager extends MediaManager { } } List<RoutingSessionInfo> getActiveMediaSession() { /** * Returns the list of currently active {@link RoutingSessionInfo routing sessions} known to the * system. */ @NonNull List<RoutingSessionInfo> getActiveRoutingSessions() { List<RoutingSessionInfo> infos = new ArrayList<>(); infos.add(mRouterManager.getSystemRoutingSession(null)); infos.addAll(mRouterManager.getRemoteSessions()); Loading Loading @@ -631,7 +628,8 @@ public class InfoMediaManager extends MediaManager { } /** * Ignore callback here since we'll also receive {@link onRequestFailed} with reason code. * Ignore callback here since we'll also receive{@link * MediaRouter2Manager.Callback#onRequestFailed onRequestFailed} with reason code. */ @Override public void onTransferFailed(RoutingSessionInfo session, MediaRoute2Info route) { Loading packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getSelectableMediaDevice() { return mInfoMediaManager.getSelectableMediaDevice(); return mInfoMediaManager.getSelectableMediaDevices(); } /** Loading @@ -355,7 +355,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getDeselectableMediaDevice() { return mInfoMediaManager.getDeselectableMediaDevice(); return mInfoMediaManager.getDeselectableMediaDevices(); } /** Loading @@ -371,7 +371,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getSelectedMediaDevice() { return mInfoMediaManager.getSelectedMediaDevice(); return mInfoMediaManager.getSelectedMediaDevices(); } /** Loading Loading @@ -433,7 +433,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return current active session list{@link android.media.RoutingSessionInfo} */ public List<RoutingSessionInfo> getActiveMediaSession() { return mInfoMediaManager.getActiveMediaSession(); return mInfoMediaManager.getActiveRoutingSessions(); } /** Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -668,7 +668,7 @@ public class InfoMediaManagerTest { public void getSelectableMediaDevice_packageNameIsNull_returnFalse() { mInfoMediaManager.mPackageName = null; assertThat(mInfoMediaManager.getSelectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getSelectableMediaDevices()).isEmpty(); } @Test Loading @@ -680,14 +680,14 @@ public class InfoMediaManagerTest { mShadowRouter2Manager.setRoutingSessions(routingSessionInfos); when(info.getClientPackageName()).thenReturn("com.fake.packagename"); assertThat(mInfoMediaManager.getSelectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getSelectableMediaDevices()).isEmpty(); } @Test public void getDeselectableMediaDevice_packageNameIsNull_returnFalse() { mInfoMediaManager.mPackageName = null; assertThat(mInfoMediaManager.getDeselectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getDeselectableMediaDevices()).isEmpty(); } @Test Loading @@ -703,7 +703,7 @@ public class InfoMediaManagerTest { when(mediaRoute2Info.getName()).thenReturn(TEST_NAME); when(mediaRoute2Info.getId()).thenReturn(TEST_ID); final List<MediaDevice> mediaDevices = mInfoMediaManager.getDeselectableMediaDevice(); final List<MediaDevice> mediaDevices = mInfoMediaManager.getDeselectableMediaDevices(); assertThat(mediaDevices.size()).isEqualTo(1); assertThat(mediaDevices.get(0).getName()).isEqualTo(TEST_NAME); Loading Loading @@ -797,7 +797,7 @@ public class InfoMediaManagerTest { mShadowRouter2Manager.setSystemRoutingSession(sysSessionInfo); mShadowRouter2Manager.setRemoteSessions(infos); assertThat(mInfoMediaManager.getActiveMediaSession()) assertThat(mInfoMediaManager.getActiveRoutingSessions()) .containsExactlyElementsIn(activeSessionInfos); } Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ public class LocalMediaManagerTest { final RoutingSessionInfo info = mock(RoutingSessionInfo.class); when(info.getId()).thenReturn(TEST_SESSION_ID); routingSessionInfos.add(info); when(mInfoMediaManager.getActiveMediaSession()).thenReturn(routingSessionInfos); when(mInfoMediaManager.getActiveRoutingSessions()).thenReturn(routingSessionInfos); assertThat(mLocalMediaManager.getActiveMediaSession().get(0).getId()) .matches(TEST_SESSION_ID); Loading Loading @@ -546,7 +546,7 @@ public class LocalMediaManagerTest { final RoutingSessionInfo info = mock(RoutingSessionInfo.class); when(info.getId()).thenReturn(TEST_SESSION_ID); routingSessionInfos.add(info); when(mInfoMediaManager.getActiveMediaSession()).thenReturn(routingSessionInfos); when(mInfoMediaManager.getActiveRoutingSessions()).thenReturn(routingSessionInfos); mLocalMediaManager.adjustSessionVolume(TEST_SESSION_ID, 10); Loading Loading
packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java +93 −95 Original line number Diff line number Diff line Loading @@ -142,13 +142,12 @@ public class InfoMediaManager extends MediaManager { * Transfer MediaDevice for media without package name. */ boolean connectDeviceWithoutPackageName(MediaDevice device) { boolean isConnected = false; final RoutingSessionInfo info = mRouterManager.getSystemRoutingSession(null); if (info != null) { mRouterManager.transfer(info, device.mRouteInfo); isConnected = true; return true; } return isConnected; return false; } /** Loading @@ -164,17 +163,16 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.selectRoute(info, device.mRouteInfo); return true; } if (info == null || !info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { Log.w(TAG, "addDeviceToPlayMedia() Ignoring selecting a non-selectable device : " + device.getName()); return false; } mRouterManager.selectRoute(info, device.mRouteInfo); return true; } private RoutingSessionInfo getRoutingSessionInfo() { return getRoutingSessionInfo(mPackageName); } Loading @@ -190,8 +188,7 @@ public class InfoMediaManager extends MediaManager { } boolean isRoutingSessionAvailableForVolumeControl() { List<RoutingSessionInfo> sessions = mRouterManager.getRoutingSessions(mPackageName); List<RoutingSessionInfo> sessions = mRouterManager.getRoutingSessions(mPackageName); for (RoutingSessionInfo session : sessions) { if (!session.isSystemSession() Loading Loading @@ -230,17 +227,16 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.deselectRoute(info, device.mRouteInfo); return true; } if (info == null || !info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { Log.w(TAG, "removeDeviceFromMedia() Ignoring deselecting a non-deselectable device : " + device.getName()); return false; } mRouterManager.deselectRoute(info, device.mRouteInfo); return true; } /** * Release session to stop playing media on MediaDevice. */ Loading @@ -251,31 +247,35 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo sessionInfo = getRoutingSessionInfo(); if (sessionInfo == null) { Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); return false; } if (sessionInfo != null) { mRouterManager.releaseSession(sessionInfo); return true; } Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); return false; } /** * Get the MediaDevice list that can be added to current media. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that can be added to the current {@link * RoutingSessionInfo routing session}. */ List<MediaDevice> getSelectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getSelectableMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectableMediaDevice() package name is null or empty!"); return deviceList; Log.w(TAG, "getSelectableMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.w(TAG, "getSelectableMediaDevices() cannot find selectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getSelectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -283,26 +283,25 @@ public class InfoMediaManager extends MediaManager { return deviceList; } Log.w(TAG, "getSelectableMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; } /** * Get the MediaDevice list that can be removed from current media session. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that can be deselected from the current * {@link RoutingSessionInfo routing session}. */ List<MediaDevice> getDeselectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getDeselectableMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.d(TAG, "getDeselectableMediaDevice() package name is null or empty!"); return deviceList; Log.d(TAG, "getDeselectableMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.d(TAG, "getDeselectableMediaDevices() cannot find deselectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getDeselectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -310,26 +309,26 @@ public class InfoMediaManager extends MediaManager { } return deviceList; } Log.d(TAG, "getDeselectableMediaDevice() cannot found deselectable MediaDevice from : " + mPackageName); return deviceList; } /** * Get the MediaDevice list that has been selected to current media. * * @return list of MediaDevice * Returns the list of {@link MediaDevice media devices} that are selected in the current {@link * RoutingSessionInfo routing session}. */ List<MediaDevice> getSelectedMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); @NonNull List<MediaDevice> getSelectedMediaDevices() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectedMediaDevice() package name is null or empty!"); return deviceList; Log.w(TAG, "getSelectedMediaDevices() package name is null or empty!"); return Collections.emptyList(); } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { if (info == null) { Log.w(TAG, "getSelectedMediaDevices() cannot find selectable MediaDevice from : " + mPackageName); return Collections.emptyList(); } final List<MediaDevice> deviceList = new ArrayList<>(); for (MediaRoute2Info route : mRouterManager.getSelectedRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName, mPreferenceItemMap.get(route.getId()))); Loading @@ -337,12 +336,6 @@ public class InfoMediaManager extends MediaManager { return deviceList; } Log.w(TAG, "getSelectedMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; } void adjustSessionVolume(RoutingSessionInfo info, int volume) { if (info == null) { Log.w(TAG, "Unable to adjust session volume. RoutingSessionInfo is empty"); Loading @@ -364,15 +357,14 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { Log.d(TAG, "adjustSessionVolume() adjust volume : " + volume + ", with : " if (info == null) { Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); mRouterManager.setSessionVolume(info, volume); return; } Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); Log.d(TAG, "adjustSessionVolume() adjust volume: " + volume + ", with : " + mPackageName); mRouterManager.setSessionVolume(info, volume); } /** Loading @@ -387,15 +379,15 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolumeMax(); } Log.w(TAG, "getSessionVolumeMax() can't found corresponding RoutingSession with : " if (info == null) { Log.w(TAG, "getSessionVolumeMax() can't find corresponding RoutingSession with : " + mPackageName); return -1; } return info.getVolumeMax(); } /** * Gets the current volume of the {@link android.media.RoutingSessionInfo}. * Loading @@ -408,15 +400,15 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolume(); } Log.w(TAG, "getSessionVolume() can't found corresponding RoutingSession with : " if (info == null) { Log.w(TAG, "getSessionVolume() can't find corresponding RoutingSession with : " + mPackageName); return -1; } return info.getVolume(); } CharSequence getSessionName() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "Unable to get session name. The package name is null or empty!"); Loading @@ -424,14 +416,14 @@ public class InfoMediaManager extends MediaManager { } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getName(); } if (info == null) { Log.w(TAG, "Unable to get session name for package: " + mPackageName); return null; } return info.getName(); } boolean shouldDisableMediaOutput(String packageName) { if (TextUtils.isEmpty(packageName)) { Log.w(TAG, "shouldDisableMediaOutput() package name is null or empty!"); Loading Loading @@ -473,7 +465,12 @@ public class InfoMediaManager extends MediaManager { } } List<RoutingSessionInfo> getActiveMediaSession() { /** * Returns the list of currently active {@link RoutingSessionInfo routing sessions} known to the * system. */ @NonNull List<RoutingSessionInfo> getActiveRoutingSessions() { List<RoutingSessionInfo> infos = new ArrayList<>(); infos.add(mRouterManager.getSystemRoutingSession(null)); infos.addAll(mRouterManager.getRemoteSessions()); Loading Loading @@ -631,7 +628,8 @@ public class InfoMediaManager extends MediaManager { } /** * Ignore callback here since we'll also receive {@link onRequestFailed} with reason code. * Ignore callback here since we'll also receive{@link * MediaRouter2Manager.Callback#onRequestFailed onRequestFailed} with reason code. */ @Override public void onTransferFailed(RoutingSessionInfo session, MediaRoute2Info route) { Loading
packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getSelectableMediaDevice() { return mInfoMediaManager.getSelectableMediaDevice(); return mInfoMediaManager.getSelectableMediaDevices(); } /** Loading @@ -355,7 +355,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getDeselectableMediaDevice() { return mInfoMediaManager.getDeselectableMediaDevice(); return mInfoMediaManager.getDeselectableMediaDevices(); } /** Loading @@ -371,7 +371,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return list of MediaDevice */ public List<MediaDevice> getSelectedMediaDevice() { return mInfoMediaManager.getSelectedMediaDevice(); return mInfoMediaManager.getSelectedMediaDevices(); } /** Loading Loading @@ -433,7 +433,7 @@ public class LocalMediaManager implements BluetoothCallback { * @return current active session list{@link android.media.RoutingSessionInfo} */ public List<RoutingSessionInfo> getActiveMediaSession() { return mInfoMediaManager.getActiveMediaSession(); return mInfoMediaManager.getActiveRoutingSessions(); } /** Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -668,7 +668,7 @@ public class InfoMediaManagerTest { public void getSelectableMediaDevice_packageNameIsNull_returnFalse() { mInfoMediaManager.mPackageName = null; assertThat(mInfoMediaManager.getSelectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getSelectableMediaDevices()).isEmpty(); } @Test Loading @@ -680,14 +680,14 @@ public class InfoMediaManagerTest { mShadowRouter2Manager.setRoutingSessions(routingSessionInfos); when(info.getClientPackageName()).thenReturn("com.fake.packagename"); assertThat(mInfoMediaManager.getSelectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getSelectableMediaDevices()).isEmpty(); } @Test public void getDeselectableMediaDevice_packageNameIsNull_returnFalse() { mInfoMediaManager.mPackageName = null; assertThat(mInfoMediaManager.getDeselectableMediaDevice()).isEmpty(); assertThat(mInfoMediaManager.getDeselectableMediaDevices()).isEmpty(); } @Test Loading @@ -703,7 +703,7 @@ public class InfoMediaManagerTest { when(mediaRoute2Info.getName()).thenReturn(TEST_NAME); when(mediaRoute2Info.getId()).thenReturn(TEST_ID); final List<MediaDevice> mediaDevices = mInfoMediaManager.getDeselectableMediaDevice(); final List<MediaDevice> mediaDevices = mInfoMediaManager.getDeselectableMediaDevices(); assertThat(mediaDevices.size()).isEqualTo(1); assertThat(mediaDevices.get(0).getName()).isEqualTo(TEST_NAME); Loading Loading @@ -797,7 +797,7 @@ public class InfoMediaManagerTest { mShadowRouter2Manager.setSystemRoutingSession(sysSessionInfo); mShadowRouter2Manager.setRemoteSessions(infos); assertThat(mInfoMediaManager.getActiveMediaSession()) assertThat(mInfoMediaManager.getActiveRoutingSessions()) .containsExactlyElementsIn(activeSessionInfos); } Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ public class LocalMediaManagerTest { final RoutingSessionInfo info = mock(RoutingSessionInfo.class); when(info.getId()).thenReturn(TEST_SESSION_ID); routingSessionInfos.add(info); when(mInfoMediaManager.getActiveMediaSession()).thenReturn(routingSessionInfos); when(mInfoMediaManager.getActiveRoutingSessions()).thenReturn(routingSessionInfos); assertThat(mLocalMediaManager.getActiveMediaSession().get(0).getId()) .matches(TEST_SESSION_ID); Loading Loading @@ -546,7 +546,7 @@ public class LocalMediaManagerTest { final RoutingSessionInfo info = mock(RoutingSessionInfo.class); when(info.getId()).thenReturn(TEST_SESSION_ID); routingSessionInfos.add(info); when(mInfoMediaManager.getActiveMediaSession()).thenReturn(routingSessionInfos); when(mInfoMediaManager.getActiveRoutingSessions()).thenReturn(routingSessionInfos); mLocalMediaManager.adjustSessionVolume(TEST_SESSION_ID, 10); Loading