hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.settingslib.media; |
| 17 | |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 18 | import static android.media.MediaRoute2Info.TYPE_BLUETOOTH_A2DP; |
| 19 | import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER; |
| 20 | import static android.media.MediaRoute2Info.TYPE_GROUP; |
| 21 | import static android.media.MediaRoute2Info.TYPE_HEARING_AID; |
| 22 | import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER; |
| 23 | import static android.media.MediaRoute2Info.TYPE_REMOTE_TV; |
| 24 | import static android.media.MediaRoute2Info.TYPE_UNKNOWN; |
| 25 | import static android.media.MediaRoute2Info.TYPE_WIRED_HEADPHONES; |
| 26 | import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 27 | |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 28 | import android.app.Notification; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 29 | import android.bluetooth.BluetoothAdapter; |
| 30 | import android.bluetooth.BluetoothDevice; |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 31 | import android.content.Context; |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 32 | import android.media.MediaRoute2Info; |
| 33 | import android.media.MediaRouter2Manager; |
hughchen | df7b838 | 2020-02-03 17:48:49 +0800 | [diff] [blame] | 34 | import android.media.RoutingSessionInfo; |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 35 | import android.text.TextUtils; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 36 | import android.util.Log; |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 37 | |
hughchen | bd0dd49 | 2019-01-08 14:34:10 +0800 | [diff] [blame] | 38 | import com.android.internal.annotations.VisibleForTesting; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 39 | import com.android.settingslib.bluetooth.CachedBluetoothDevice; |
| 40 | import com.android.settingslib.bluetooth.LocalBluetoothManager; |
hughchen | bd0dd49 | 2019-01-08 14:34:10 +0800 | [diff] [blame] | 41 | |
hughchen | 6ab62ca | 2020-02-12 10:40:04 +0800 | [diff] [blame] | 42 | import java.util.ArrayList; |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 43 | import java.util.List; |
| 44 | import java.util.concurrent.Executor; |
| 45 | import java.util.concurrent.Executors; |
| 46 | |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 47 | /** |
| 48 | * InfoMediaManager provide interface to get InfoMediaDevice list. |
| 49 | */ |
| 50 | public class InfoMediaManager extends MediaManager { |
| 51 | |
| 52 | private static final String TAG = "InfoMediaManager"; |
| 53 | |
hughchen | bd0dd49 | 2019-01-08 14:34:10 +0800 | [diff] [blame] | 54 | @VisibleForTesting |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 55 | final RouterManagerCallback mMediaRouterCallback = new RouterManagerCallback(); |
hughchen | bd0dd49 | 2019-01-08 14:34:10 +0800 | [diff] [blame] | 56 | @VisibleForTesting |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 57 | final Executor mExecutor = Executors.newSingleThreadExecutor(); |
hughchen | bd0dd49 | 2019-01-08 14:34:10 +0800 | [diff] [blame] | 58 | @VisibleForTesting |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 59 | MediaRouter2Manager mRouterManager; |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 60 | @VisibleForTesting |
| 61 | String mPackageName; |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 62 | |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 63 | private MediaDevice mCurrentConnectedDevice; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 64 | private LocalBluetoothManager mBluetoothManager; |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 65 | |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 66 | public InfoMediaManager(Context context, String packageName, Notification notification, |
| 67 | LocalBluetoothManager localBluetoothManager) { |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 68 | super(context, notification); |
| 69 | |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 70 | mRouterManager = MediaRouter2Manager.getInstance(context); |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 71 | mBluetoothManager = localBluetoothManager; |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 72 | if (!TextUtils.isEmpty(packageName)) { |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 73 | mPackageName = packageName; |
| 74 | } |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public void startScan() { |
| 79 | mMediaDevices.clear(); |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 80 | mRouterManager.registerCallback(mExecutor, mMediaRouterCallback); |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 81 | refreshDevices(); |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 82 | } |
| 83 | |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 84 | @Override |
| 85 | public void stopScan() { |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 86 | mRouterManager.unregisterCallback(mMediaRouterCallback); |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 87 | } |
| 88 | |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 89 | /** |
| 90 | * Get current device that played media. |
| 91 | * @return MediaDevice |
| 92 | */ |
hughchen | 6ab62ca | 2020-02-12 10:40:04 +0800 | [diff] [blame] | 93 | MediaDevice getCurrentConnectedDevice() { |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 94 | return mCurrentConnectedDevice; |
| 95 | } |
| 96 | |
hughchen | 6ab62ca | 2020-02-12 10:40:04 +0800 | [diff] [blame] | 97 | /** |
| 98 | * Transfer MediaDevice for media without package name. |
| 99 | */ |
| 100 | boolean connectDeviceWithoutPackageName(MediaDevice device) { |
| 101 | boolean isConnected = false; |
| 102 | final List<RoutingSessionInfo> infos = mRouterManager.getActiveSessions(); |
| 103 | if (infos.size() > 0) { |
| 104 | final RoutingSessionInfo info = infos.get(0); |
| 105 | final MediaRouter2Manager.RoutingController controller = |
| 106 | mRouterManager.getControllerForSession(info); |
| 107 | |
| 108 | controller.transferToRoute(device.mRouteInfo); |
| 109 | isConnected = true; |
| 110 | } |
| 111 | return isConnected; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Add a MediaDevice to let it play current media. |
| 116 | * |
| 117 | * @param device MediaDevice |
| 118 | * @return If add device successful return {@code true}, otherwise return {@code false} |
| 119 | */ |
| 120 | boolean addDeviceToPlayMedia(MediaDevice device) { |
| 121 | if (TextUtils.isEmpty(mPackageName)) { |
| 122 | Log.w(TAG, "addDeviceToPlayMedia() package name is null or empty!"); |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 127 | if (info != null && info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { |
| 128 | mRouterManager.getControllerForSession(info).selectRoute(device.mRouteInfo); |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | Log.w(TAG, "addDeviceToPlayMedia() Ignoring selecting a non-selectable device : " |
| 133 | + device.getName()); |
| 134 | |
| 135 | return false; |
| 136 | } |
| 137 | |
| 138 | private RoutingSessionInfo getRoutingSessionInfo() { |
| 139 | for (RoutingSessionInfo info : mRouterManager.getRoutingSessions(mPackageName)) { |
| 140 | if (TextUtils.equals(info.getClientPackageName(), mPackageName)) { |
| 141 | return info; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | Log.w(TAG, "RoutingSessionInfo() cannot found match packagename : " + mPackageName); |
| 146 | return null; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Remove a {@code device} from current media. |
| 151 | * |
| 152 | * @param device MediaDevice |
| 153 | * @return If device stop successful return {@code true}, otherwise return {@code false} |
| 154 | */ |
| 155 | boolean removeDeviceFromPlayMedia(MediaDevice device) { |
| 156 | if (TextUtils.isEmpty(mPackageName)) { |
| 157 | Log.w(TAG, "removeDeviceFromMedia() package name is null or empty!"); |
| 158 | return false; |
| 159 | } |
| 160 | |
| 161 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 162 | if (info != null && info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { |
| 163 | mRouterManager.getControllerForSession(info).deselectRoute(device.mRouteInfo); |
| 164 | return true; |
| 165 | } |
| 166 | |
| 167 | Log.w(TAG, "removeDeviceFromMedia() Ignoring deselecting a non-deselectable device : " |
| 168 | + device.getName()); |
| 169 | |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | /** |
hughchen | 61bced0 | 2020-02-20 18:46:32 +0800 | [diff] [blame] | 174 | * Release session to stop playing media on MediaDevice. |
| 175 | */ |
| 176 | boolean releaseSession() { |
| 177 | if (TextUtils.isEmpty(mPackageName)) { |
| 178 | Log.w(TAG, "releaseSession() package name is null or empty!"); |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 183 | if (info != null) { |
| 184 | mRouterManager.getControllerForSession(info).release(); |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); |
| 189 | |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | /** |
hughchen | 6ab62ca | 2020-02-12 10:40:04 +0800 | [diff] [blame] | 194 | * Get the MediaDevice list that can be added to current media. |
| 195 | * |
| 196 | * @return list of MediaDevice |
| 197 | */ |
| 198 | List<MediaDevice> getSelectableMediaDevice() { |
| 199 | final List<MediaDevice> deviceList = new ArrayList<>(); |
| 200 | if (TextUtils.isEmpty(mPackageName)) { |
| 201 | Log.w(TAG, "getSelectableMediaDevice() package name is null or empty!"); |
| 202 | return deviceList; |
| 203 | } |
| 204 | |
| 205 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 206 | if (info != null) { |
| 207 | for (MediaRoute2Info route : mRouterManager.getControllerForSession(info) |
| 208 | .getSelectableRoutes()) { |
| 209 | deviceList.add(new InfoMediaDevice(mContext, mRouterManager, |
| 210 | route, mPackageName)); |
| 211 | } |
| 212 | return deviceList; |
| 213 | } |
| 214 | |
| 215 | Log.w(TAG, "getSelectableMediaDevice() cannot found selectable MediaDevice from : " |
| 216 | + mPackageName); |
| 217 | |
| 218 | return deviceList; |
| 219 | } |
| 220 | |
| 221 | /** |
timhypeng | 6bbd555 | 2020-02-17 14:53:45 +0800 | [diff] [blame] | 222 | * Get the MediaDevice list that has been selected to current media. |
| 223 | * |
| 224 | * @return list of MediaDevice |
| 225 | */ |
| 226 | List<MediaDevice> getSelectedMediaDevice() { |
| 227 | final List<MediaDevice> deviceList = new ArrayList<>(); |
| 228 | if (TextUtils.isEmpty(mPackageName)) { |
| 229 | Log.w(TAG, "getSelectedMediaDevice() package name is null or empty!"); |
| 230 | return deviceList; |
| 231 | } |
| 232 | |
| 233 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 234 | if (info != null) { |
| 235 | for (MediaRoute2Info route : mRouterManager.getControllerForSession(info) |
| 236 | .getSelectedRoutes()) { |
| 237 | deviceList.add(new InfoMediaDevice(mContext, mRouterManager, |
| 238 | route, mPackageName)); |
| 239 | } |
| 240 | return deviceList; |
| 241 | } |
| 242 | |
| 243 | Log.w(TAG, "getSelectedMediaDevice() cannot found selectable MediaDevice from : " |
| 244 | + mPackageName); |
| 245 | |
| 246 | return deviceList; |
| 247 | } |
| 248 | |
| 249 | /** |
hughchen | 6ab62ca | 2020-02-12 10:40:04 +0800 | [diff] [blame] | 250 | * Adjust the volume of {@link android.media.RoutingSessionInfo}. |
| 251 | * |
| 252 | * @param volume the value of volume |
| 253 | */ |
| 254 | void adjustSessionVolume(int volume) { |
| 255 | if (TextUtils.isEmpty(mPackageName)) { |
| 256 | Log.w(TAG, "adjustSessionVolume() package name is null or empty!"); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 261 | if (info != null) { |
| 262 | Log.d(TAG, "adjustSessionVolume() adjust volume : " + volume + ", with : " |
| 263 | + mPackageName); |
| 264 | mRouterManager.setSessionVolume(info, volume); |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " |
| 269 | + mPackageName); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Gets the maximum volume of the {@link android.media.RoutingSessionInfo}. |
| 274 | * |
| 275 | * @return maximum volume of the session, and return -1 if not found. |
| 276 | */ |
| 277 | public int getSessionVolumeMax() { |
| 278 | if (TextUtils.isEmpty(mPackageName)) { |
| 279 | Log.w(TAG, "getSessionVolumeMax() package name is null or empty!"); |
| 280 | return -1; |
| 281 | } |
| 282 | |
| 283 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 284 | if (info != null) { |
| 285 | return info.getVolumeMax(); |
| 286 | } |
| 287 | |
| 288 | Log.w(TAG, "getSessionVolumeMax() can't found corresponding RoutingSession with : " |
| 289 | + mPackageName); |
| 290 | return -1; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Gets the current volume of the {@link android.media.RoutingSessionInfo}. |
| 295 | * |
| 296 | * @return current volume of the session, and return -1 if not found. |
| 297 | */ |
| 298 | public int getSessionVolume() { |
| 299 | if (TextUtils.isEmpty(mPackageName)) { |
| 300 | Log.w(TAG, "getSessionVolume() package name is null or empty!"); |
| 301 | return -1; |
| 302 | } |
| 303 | |
| 304 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 305 | if (info != null) { |
| 306 | return info.getVolume(); |
| 307 | } |
| 308 | |
| 309 | Log.w(TAG, "getSessionVolume() can't found corresponding RoutingSession with : " |
| 310 | + mPackageName); |
| 311 | return -1; |
| 312 | } |
| 313 | |
Tim Peng | 635b04a | 2020-03-05 13:08:02 +0800 | [diff] [blame^] | 314 | CharSequence getSessionName() { |
| 315 | if (TextUtils.isEmpty(mPackageName)) { |
| 316 | Log.w(TAG, "Unable to get session name. The package name is null or empty!"); |
| 317 | return null; |
| 318 | } |
| 319 | |
| 320 | final RoutingSessionInfo info = getRoutingSessionInfo(); |
| 321 | if (info != null) { |
| 322 | return info.getName(); |
| 323 | } |
| 324 | |
| 325 | Log.w(TAG, "Unable to get session name for package: " + mPackageName); |
| 326 | return null; |
| 327 | } |
| 328 | |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 329 | private void refreshDevices() { |
| 330 | mMediaDevices.clear(); |
| 331 | mCurrentConnectedDevice = null; |
| 332 | if (TextUtils.isEmpty(mPackageName)) { |
| 333 | buildAllRoutes(); |
| 334 | } else { |
| 335 | buildAvailableRoutes(); |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 336 | } |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 337 | dispatchDeviceListAdded(); |
| 338 | } |
| 339 | |
| 340 | private void buildAllRoutes() { |
| 341 | for (MediaRoute2Info route : mRouterManager.getAllRoutes()) { |
hughchen | 61bced0 | 2020-02-20 18:46:32 +0800 | [diff] [blame] | 342 | if (route.isSystemRoute()) { |
| 343 | addMediaDevice(route); |
| 344 | } |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
| 348 | private void buildAvailableRoutes() { |
| 349 | for (MediaRoute2Info route : mRouterManager.getAvailableRoutes(mPackageName)) { |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 350 | addMediaDevice(route); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | private void addMediaDevice(MediaRoute2Info route) { |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 355 | final int deviceType = route.getType(); |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 356 | MediaDevice mediaDevice = null; |
| 357 | switch (deviceType) { |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 358 | case TYPE_UNKNOWN: |
| 359 | case TYPE_REMOTE_TV: |
| 360 | case TYPE_REMOTE_SPEAKER: |
| 361 | case TYPE_GROUP: |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 362 | //TODO(b/148765806): use correct device type once api is ready. |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 363 | mediaDevice = new InfoMediaDevice(mContext, mRouterManager, route, |
| 364 | mPackageName); |
| 365 | if (!TextUtils.isEmpty(mPackageName) |
| 366 | && TextUtils.equals(route.getClientPackageName(), mPackageName)) { |
| 367 | mCurrentConnectedDevice = mediaDevice; |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 368 | } |
| 369 | break; |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 370 | case TYPE_BUILTIN_SPEAKER: |
| 371 | case TYPE_WIRED_HEADSET: |
| 372 | case TYPE_WIRED_HEADPHONES: |
| 373 | mediaDevice = |
| 374 | new PhoneMediaDevice(mContext, mRouterManager, route, mPackageName); |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 375 | break; |
hughchen | 6283741 | 2020-02-24 17:03:26 +0800 | [diff] [blame] | 376 | case TYPE_HEARING_AID: |
| 377 | case TYPE_BLUETOOTH_A2DP: |
hughchen | 491b9fc | 2020-02-05 18:31:36 +0800 | [diff] [blame] | 378 | final BluetoothDevice device = |
| 379 | BluetoothAdapter.getDefaultAdapter().getRemoteDevice(route.getOriginalId()); |
| 380 | final CachedBluetoothDevice cachedDevice = |
| 381 | mBluetoothManager.getCachedDeviceManager().findDevice(device); |
| 382 | mediaDevice = new BluetoothMediaDevice(mContext, cachedDevice, mRouterManager, |
| 383 | route, mPackageName); |
| 384 | break; |
| 385 | default: |
| 386 | Log.w(TAG, "addMediaDevice() unknown device type : " + deviceType); |
| 387 | break; |
| 388 | |
| 389 | } |
| 390 | |
| 391 | if (mediaDevice != null) { |
| 392 | mMediaDevices.add(mediaDevice); |
hughchen | 0d20204 | 2020-01-17 18:30:03 +0800 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
| 396 | class RouterManagerCallback extends MediaRouter2Manager.Callback { |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 397 | |
| 398 | @Override |
hughchen | e6a4f48 | 2019-10-18 17:34:15 +0800 | [diff] [blame] | 399 | public void onRoutesAdded(List<MediaRoute2Info> routes) { |
| 400 | refreshDevices(); |
| 401 | } |
| 402 | |
| 403 | @Override |
| 404 | public void onControlCategoriesChanged(String packageName, List<String> controlCategories) { |
| 405 | if (TextUtils.equals(mPackageName, packageName)) { |
| 406 | refreshDevices(); |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 407 | } |
| 408 | } |
hughchen | df7b838 | 2020-02-03 17:48:49 +0800 | [diff] [blame] | 409 | |
| 410 | @Override |
| 411 | public void onRoutesChanged(List<MediaRoute2Info> routes) { |
| 412 | refreshDevices(); |
| 413 | } |
hughchen | b3d68f6 | 2020-02-11 14:30:14 +0800 | [diff] [blame] | 414 | |
| 415 | @Override |
| 416 | public void onRoutesRemoved(List<MediaRoute2Info> routes) { |
| 417 | refreshDevices(); |
| 418 | } |
hughchen | a73686f | 2018-11-12 17:42:08 +0800 | [diff] [blame] | 419 | } |
| 420 | } |