According to the code for MediaRouteChooserDialog, one needs to override onRouteChanged() to discover routes by category reliably: https://android.googlesource.com/platform/frameworks/support/+/2838eb1aea3fd1fac66526e1418f4739625bc4a1/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java#239 For instance, the Cast MRP might actually add new route without knowing if the Cast application is available which means it later will change the route with the matching category but onRouteAdded won't be called on the callback. In practice it means sometimes Chrome reports false screen availability via the Presentation API.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a commit 4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a Author: avayvod <avayvod@chromium.org> Date: Tue Mar 29 18:41:36 2016 [Android, Cast] Take onRouteChanged() into account to discover compatible Cast devices. BUG= 598721 TEST=unit tests + manual testing Review URL: https://codereview.chromium.org/1840093002 Cr-Commit-Position: refs/heads/master@{#383779} [modify] https://crrev.com/4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteController.java [modify] https://crrev.com/4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/CastMediaRouteProvider.java [modify] https://crrev.com/4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/DiscoveryCallback.java [modify] https://crrev.com/4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a/chrome/android/junit/src/org/chromium/chrome/browser/media/router/cast/DiscoveryCallbackTest.java
Your change meets the bar and is auto-approved for M50 (branch: 2661)
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b commit 75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b Author: Anton Vayvod <avayvod@google.com> Date: Tue Mar 29 19:04:32 2016 [Android, Cast] Take onRouteChanged() into account to discover compatible Cast devices. BUG= 598721 TEST=unit tests + manual testing Review URL: https://codereview.chromium.org/1840093002 Cr-Commit-Position: refs/heads/master@{#383779} (cherry picked from commit 4b7cc56984e3014b6b96a7a83a7e1bafc7713c3a) Review URL: https://codereview.chromium.org/1840063003 . Cr-Commit-Position: refs/branch-heads/2661@{#422} Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081} [modify] https://crrev.com/75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteController.java [modify] https://crrev.com/75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/CastMediaRouteProvider.java [modify] https://crrev.com/75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/DiscoveryCallback.java [modify] https://crrev.com/75f23a6e3ab5b8166f7fcb868be2e6f72ef2085b/chrome/android/junit/src/org/chromium/chrome/browser/media/router/cast/DiscoveryCallbackTest.java
Comment 1 by avayvod@chromium.org
, Mar 29 2016