Clear preferred feature when unregistering MediaRouter2

MediaRouter2Managers' preferred feature didn't get cleared even when the
MediaRouter2 is unregistered/died. As a result, when an app is
reinstalled/relaunched, the routes for the previous process are still
shown in the MediaRouter2Manager.

This CL fixes the problem.

Bug: 158824569
Test: Passed CTS and mediaroutertest
      Also tested with reinstalling support7Demos.
Change-Id: Ib5d84c41862177af32931e0d69b02f461105bba6
This commit is contained in:
Hyundo Moon
2020-06-12 19:36:10 +09:00
parent 6dca466770
commit ac9df100f5
2 changed files with 14 additions and 4 deletions

View File

@@ -576,6 +576,10 @@ public final class MediaRouter2Manager {
}
void updatePreferredFeatures(String packageName, List<String> preferredFeatures) {
if (preferredFeatures == null) {
mPreferredFeaturesMap.remove(packageName);
return;
}
List<String> prevFeatures = mPreferredFeaturesMap.put(packageName, preferredFeatures);
if ((prevFeatures == null && preferredFeatures.size() == 0)
|| Objects.equals(preferredFeatures, prevFeatures)) {