[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 3a73358157 -s ours

am skip reason: subject contains skip directive

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Car/Media/+/2116197

Change-Id: I6c4077c0b40dcd8f975e59dca4f3693820ec4fac
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/car/media/MediaActivity.java b/src/com/android/car/media/MediaActivity.java
index b437a1a..591285a 100644
--- a/src/com/android/car/media/MediaActivity.java
+++ b/src/com/android/car/media/MediaActivity.java
@@ -426,10 +426,6 @@
                 break;
             case BROWSING:
                 if (oldMode == Mode.PLAYBACK) {
-                    // When switching from PLAYBACK mode to BROWSING mode, if a CarUiRecyclerView
-                    // shows up and it's in rotary mode, restore focus in the CarUiRecyclerView.
-                    mMediaActivityController.restoreFocusInCurrentNode();
-
                     ViewUtils.hideViewAnimated(mErrorContainer, 0);
                     ViewUtils.showViewAnimated(mBrowseContainer, 0);
                     animateOutPlaybackContainer(fadeOutDuration);
diff --git a/src/com/android/car/media/MediaActivityController.java b/src/com/android/car/media/MediaActivityController.java
index a29b40d..9882e70 100644
--- a/src/com/android/car/media/MediaActivityController.java
+++ b/src/com/android/car/media/MediaActivityController.java
@@ -406,6 +406,7 @@
         updateAppBar();
     }
 
+    @NonNull
     private BrowseViewController getControllerForItem(@NonNull MediaItemMetadata item) {
         BrowseViewController controller = mBrowseViewControllersByNode.get(item);
         if (controller == null) {
@@ -438,15 +439,15 @@
     }
 
     // If the current node has a CarUiRecyclerView and it's in rotary mode, restore focus in it.
-    void restoreFocusInCurrentNode() {
+    // Should remain private and definitely NOT be called from MediaActivity#changeModeInternal
+    // as the controller isn't ready to show the browse data of the new media source (it hasn't
+    // connected to it (b/217159531).
+    private void restoreFocusInCurrentNode() {
         MediaItemMetadata currentNode = getCurrentMediaItem();
         if (currentNode == null) {
             return;
         }
         BrowseViewController controller = getControllerForItem(currentNode);
-        if (controller == null) {
-            return;
-        }
         CarUiRecyclerView carUiRecyclerView =
                 controller.getContent().findViewById(R.id.browse_list);
         if (carUiRecyclerView != null && carUiRecyclerView instanceof LazyLayoutView