Control visibility of app_selector in toolbar menu_items

Fixes: 306196882
Test: manual
Change-Id: I75acd0e404c1289aed8ea05961e9eb489588c362
diff --git a/res/values/bools.xml b/res/values/bools.xml
new file mode 100644
index 0000000..0864ed3
--- /dev/null
+++ b/res/values/bools.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2023 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<resources>
+    <!-- A config determines whether to show menu item selector in toolbar menu items-->
+    <bool name="show_menu_item_selector">true</bool>
+</resources>
\ No newline at end of file
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 66d082f..9b5f2ac 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -16,6 +16,7 @@
 <resources>
   <overlayable name="CarRadio">
     <policy type="system|product|signature">
+      <item type="bool" name="show_menu_item_selector"/>
       <item type="color" name="accent_color"/>
       <item type="color" name="band_selector_flat_text_color"/>
       <item type="color" name="band_selector_flat_text_color_selected"/>
diff --git a/src/com/android/car/radio/RadioActivity.java b/src/com/android/car/radio/RadioActivity.java
index a9da2be..f08d936 100644
--- a/src/com/android/car/radio/RadioActivity.java
+++ b/src/com/android/car/radio/RadioActivity.java
@@ -67,7 +67,7 @@
     private ToolbarController mToolbar;
     private ViewPager mViewPager;
     private RadioPagerAdapter mRadioPagerAdapter;
-
+    private boolean mShowMenuItemSelector;
     private boolean mUseSourceLogoForAppSelector;
     private MediaTrampolineHelper mMediaTrampoline;
 
@@ -104,6 +104,8 @@
                 new RadioPagerAdapter(this, getSupportFragmentManager(), mRadioController);
         mViewPager = findViewById(R.id.viewpager);
 
+        mShowMenuItemSelector =
+                getResources().getBoolean(R.bool.show_menu_item_selector);
         mUseSourceLogoForAppSelector =
                 getResources().getBoolean(R.bool.use_media_source_logo_for_app_selector);
 
@@ -236,20 +238,21 @@
                     mRadioController.switchBand(programType);
                 })
                 .build();
-
-        Intent appSelectorIntent = MediaSource.getSourceSelectorIntent(this, false);
-        MenuItem appSelectorMenuItem = MenuItem.builder(this)
-                .setIcon(mUseSourceLogoForAppSelector
-                        ? R.drawable.logo_fm_radio : R.drawable.ic_app_switch)
-                .setTinted(!mUseSourceLogoForAppSelector)
-                .setOnClickListener(m -> startActivity(appSelectorIntent))
-                .build();
-
-        ArrayList<MenuItem> menuItems = new ArrayList<>(2);
+        ArrayList<MenuItem> menuItems = new ArrayList<>();
         if (mIsConnected) {
             menuItems.add(bandSelectorMenuItem);
         }
-        menuItems.add(appSelectorMenuItem);
+
+        if (mShowMenuItemSelector) {
+            Intent appSelectorIntent = MediaSource.getSourceSelectorIntent(this, false);
+            MenuItem appSelectorMenuItem = MenuItem.builder(this)
+                    .setIcon(mUseSourceLogoForAppSelector
+                            ? R.drawable.logo_fm_radio : R.drawable.ic_app_switch)
+                    .setTinted(!mUseSourceLogoForAppSelector)
+                    .setOnClickListener(m -> startActivity(appSelectorIntent))
+                    .build();
+            menuItems.add(appSelectorMenuItem);
+        }
         mToolbar.setMenuItems(menuItems);
     }