Tag band root nodes with EXTRA_BCRADIO_BAND_NAME_EN.
Test: build the lib and radio app, flash, run car.Media app
Bug: 75970985
Change-Id: Ie08d738741c623501278f937bbdb29d4b06bdfe9
diff --git a/car-broadcastradio-support/src/com/android/car/broadcastradio/support/media/BrowseTree.java b/car-broadcastradio-support/src/com/android/car/broadcastradio/support/media/BrowseTree.java
index ebfd8ba..c9d7285 100644
--- a/car-broadcastradio-support/src/com/android/car/broadcastradio/support/media/BrowseTree.java
+++ b/car-broadcastradio-support/src/com/android/car/broadcastradio/support/media/BrowseTree.java
@@ -95,6 +95,20 @@
*/
public static final long BCRADIO_FOLDER_TYPE_BAND = 3;
+ /**
+ * Non-localized name of the band.
+ *
+ * For now, it can only take one of the following values:
+ * - AM;
+ * - FM;
+ * - DAB;
+ * - SXM.
+ *
+ * However, in future releases the list might get extended.
+ */
+ public static final String EXTRA_BCRADIO_BAND_NAME_EN =
+ "android.media.extra.EXTRA_BCRADIO_BAND_NAME_EN";
+
private static final String NODE_ROOT = "root_id";
private static final String NODE_PROGRAMS = "programs_id";
private static final String NODE_FAVORITES = "favorites_id";
@@ -112,9 +126,9 @@
private List<MediaItem> mRootChildren;
private final AmFmChannelList mAmChannels = new AmFmChannelList(
- NODEPREFIX_BAND + "am", R.string.radio_am_text);
+ NODEPREFIX_BAND + "am", R.string.radio_am_text, "AM");
private final AmFmChannelList mFmChannels = new AmFmChannelList(
- NODEPREFIX_BAND + "fm", R.string.radio_fm_text);
+ NODEPREFIX_BAND + "fm", R.string.radio_fm_text, "FM");
private final ProgramList.OnCompleteListener mProgramListCompleteListener =
this::onProgramListUpdated;
@@ -149,8 +163,8 @@
}
private static MediaItem createFolder(MediaDescriptionCompat.Builder descBuilder,
- String mediaId, String title, boolean isPlayable, long folderType) {
- Bundle extras = new Bundle();
+ String mediaId, String title, boolean isPlayable, long folderType, Bundle extras) {
+ if (extras == null) extras = new Bundle();
extras.putLong(EXTRA_BCRADIO_FOLDER_TYPE, folderType);
MediaDescriptionCompat desc = descBuilder
@@ -317,12 +331,12 @@
if (mProgramList != null) {
mRootChildren.add(createFolder(dbld, NODE_PROGRAMS,
mBrowserService.getString(R.string.program_list_text),
- false, BCRADIO_FOLDER_TYPE_PROGRAMS));
+ false, BCRADIO_FOLDER_TYPE_PROGRAMS, null));
}
if (mFavorites != null) {
mRootChildren.add(createFolder(dbld, NODE_FAVORITES,
mBrowserService.getString(R.string.favorites_list_text),
- true, BCRADIO_FOLDER_TYPE_FAVORITES));
+ true, BCRADIO_FOLDER_TYPE_FAVORITES, null));
}
MediaItem amRoot = mAmChannels.getBandRoot();
@@ -337,12 +351,15 @@
private class AmFmChannelList {
public final @NonNull String mMediaId;
private final @StringRes int mBandName;
+ private final @NonNull String mBandNameEn;
private @Nullable List<BandDescriptor> mBands;
private @Nullable List<MediaItem> mChannels;
- private AmFmChannelList(@NonNull String mediaId, @StringRes int bandName) {
+ private AmFmChannelList(@NonNull String mediaId, @StringRes int bandName,
+ @NonNull String bandNameEn) {
mMediaId = Objects.requireNonNull(mediaId);
mBandName = bandName;
+ mBandNameEn = Objects.requireNonNull(bandNameEn);
}
public void setBands(List<BandDescriptor> bands) {
@@ -363,8 +380,10 @@
public @Nullable MediaItem getBandRoot() {
if (isEmpty()) return null;
+ Bundle extras = new Bundle();
+ extras.putString(EXTRA_BCRADIO_BAND_NAME_EN, mBandNameEn);
return createFolder(new MediaDescriptionCompat.Builder(), mMediaId,
- mBrowserService.getString(mBandName), true, BCRADIO_FOLDER_TYPE_BAND);
+ mBrowserService.getString(mBandName), true, BCRADIO_FOLDER_TYPE_BAND, extras);
}
public List<MediaItem> getChannels() {